[SciPy-User] Scikits.sparse build issue

36 views
Skip to first unread message

Anand Patil

unread,
May 3, 2011, 8:51:59 AM5/3/11
to scipy...@scipy.org
Hi all,

I was excited to notice scikits.sparse this morning. I've been waiting
for something like that to appear for a while now! I'm trying to
install the HG head on a Mac, with EPD 7.0-2 and Numpy 1.5.1. I've
installed SuiteSparse from MacPorts.

First, the following line from cholmod.pyx doesn't work with MacPorts'
SuiteSparse:

cdef extern from "suitesparse/cholmod.h":

It needs to be

cdef extern from "ufsparse/cholmod.h":

Having done that, I get a sequence of errors like the following:

python setup.py build
running build
running build_py
running build_ext
skipping 'scikits/sparse/cholmod.c' Cython extension (up-to-date)
building 'scikits.sparse.cholmod' extension
gcc -DNDEBUG -g -O3 -arch x86_64 -isysroot /Developer/SDKs/
MacOSX10.5.sdk -I/Library/Frameworks/EPD64.framework/Versions/7.0/
include -I/opt/local/include -I/Library/Frameworks/EPD64.framework/
Versions/7.0/lib/python2.7/site-packages/numpy/core/include -I/Library/
Frameworks/EPD64.framework/Versions/7.0/include/python2.7 -c scikits/
sparse/cholmod.c -o build/temp.macosx-10.6-x86_64-2.7/scikits/sparse/
cholmod.o
scikits/sparse/cholmod.c: In function
‘__pyx_f_7scikits_6sparse_7cholmod__py_sparse’:
scikits/sparse/cholmod.c:1713: error: storage size of ‘__pyx_t_10’
isn’t known

I've never used Cython and am having a hard time figuring this out.

Thanks in advance for any help,
Anand
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Nathaniel Smith

unread,
May 3, 2011, 1:10:49 PM5/3/11
to SciPy Users List
On Tue, May 3, 2011 at 5:51 AM, Anand Patil
<anand.prab...@gmail.com> wrote:
> First, the following line from cholmod.pyx doesn't work with MacPorts'
> SuiteSparse:
>
>   cdef extern from "suitesparse/cholmod.h":
>
> It needs to be
>
>   cdef extern from "ufsparse/cholmod.h":

It should probably be:
cdef extern from "cholmod.h":
and then the build system should figure out in what idiosyncratic way
cholmod has been installed on the system, and set appropriate compiler
flags so it can be found.

I really have no idea how to do this with distutils, though -- does anyone else?

> scikits/sparse/cholmod.c: In function
> ‘__pyx_f_7scikits_6sparse_7cholmod__py_sparse’:
> scikits/sparse/cholmod.c:1713: error: storage size of ‘__pyx_t_10’
> isn’t known
>
> I've never used Cython and am having a hard time figuring this out.

Could you send me the file 'scikits/sparse/cholmod.c'? This means that
there's some C type that was forward-declared, but never actually
defined, and then we tried to instantiate an instance of it. But I'll
need to see the generated code to figure out which type '__pyx_t_10'
is supposed to be.

-- Nathaniel

Anand Patil

unread,
May 4, 2011, 5:39:55 AM5/4/11
to scipy...@scipy.org
Hi Nathaniel,

Thanks for getting back to me. I'll send you cholmod.c by email.

Anand

On May 3, 6:10 pm, Nathaniel Smith <n...@pobox.com> wrote:
> On Tue, May 3, 2011 at 5:51 AM, Anand Patil
>

> SciPy-U...@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user

Nathaniel Smith

unread,
May 4, 2011, 3:16:44 PM5/4/11
to SciPy Users List
On Tue, May 3, 2011 at 10:10 AM, Nathaniel Smith <n...@pobox.com> wrote:
> On Tue, May 3, 2011 at 5:51 AM, Anand Patil
> <anand.prab...@gmail.com> wrote:
>> scikits/sparse/cholmod.c: In function
>> ‘__pyx_f_7scikits_6sparse_7cholmod__py_sparse’:
>> scikits/sparse/cholmod.c:1713: error: storage size of ‘__pyx_t_10’
>> isn’t known
>>
>> I've never used Cython and am having a hard time figuring this out.
>
> Could you send me the file 'scikits/sparse/cholmod.c'? This means that
> there's some C type that was forward-declared, but never actually
> defined, and then we tried to instantiate an instance of it. But I'll
> need to see the generated code to figure out which type '__pyx_t_10'
> is supposed to be.

Huh, this appears to be some bad interaction between numpy and cython,
rather than anything to do with my code. The offending variable comes
from doing 'cimport numpy as np' and then referring to
'np.NPY_F_CONTIGUOUS' -- this is being translated to:
enum requirements __pyx_t_10;
__pyx_t_10 = NPY_F_CONTIGUOUS;
and then gcc is complaining that 'enum requirements' is an undefined type.

What version of Numpy and Cython do you have installed?

Anand Patil

unread,
May 5, 2011, 6:03:01 AM5/5/11
to scipy...@scipy.org

On May 4, 8:16 pm, Nathaniel Smith <n...@pobox.com> wrote:
> On Tue, May 3, 2011 at 10:10 AM, Nathaniel Smith <n...@pobox.com> wrote:
> > On Tue, May 3, 2011 at 5:51 AM, Anand Patil
> > <anand.prabhakar.pa...@gmail.com> wrote:
> >> scikits/sparse/cholmod.c: In function
> >> ‘__pyx_f_7scikits_6sparse_7cholmod__py_sparse’:
> >> scikits/sparse/cholmod.c:1713: error: storage size of ‘__pyx_t_10’
> >> isn’t known
>
> >> I've never used Cython and am having a hard time figuring this out.
>
> > Could you send me the file 'scikits/sparse/cholmod.c'? This means that
> > there's some C type that was forward-declared, but never actually
> > defined, and then we tried to instantiate an instance of it. But I'll
> > need to see the generated code to figure out which type '__pyx_t_10'
> > is supposed to be.
>
> Huh, this appears to be some bad interaction between numpy and cython,
> rather than anything to do with my code. The offending variable comes
> from doing 'cimport numpy as np' and then referring to
> 'np.NPY_F_CONTIGUOUS' -- this is being translated to:
>   enum requirements __pyx_t_10;
>   __pyx_t_10 = NPY_F_CONTIGUOUS;
> and then gcc is complaining that 'enum requirements' is an undefined type.
>
> What version of Numpy and Cython do you have installed?

Cython 0.14.1, Numpy 1.5.1. Which versions do you have?

Thanks,
Anand

>
> -- Nathaniel
> _______________________________________________
> SciPy-User mailing list

> SciPy-U...@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user

Nathaniel Smith

unread,
May 5, 2011, 2:42:08 PM5/5/11
to SciPy Users List, cytho...@codespeak.net

It looks like with Cython 0.12.1, which is what I was using before, it
happens not to generate a temporary variable in this case, but Cython
0.14.1 generates the temporary variable.

I've just committed a workaround to the scikits.sparse repository:
https://code.google.com/p/scikits-sparse/source/detail?r=ad106e9c2c2d55f2022a3fb8b9282003b55666fc#
(I believe it works -- it does compile -- but technically I can't
guarantee it since for me the tests are now failing with an "illegal
instruction" error inside BLAS. But I think this must be an unrelated
Ubuntu screwup. Yay software.)

And I'll see about poking Cython upstream to get this fixed...

-- Nathaniel
_______________________________________________
SciPy-User mailing list

SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Anand Patil

unread,
May 6, 2011, 5:05:12 AM5/6/11
to scipy...@scipy.org
Thanks, Nathaniel! I had to make a few more changes to get the tests
to run on my setup, which is:

- Mac
- Python, Numpy, SciPy from EPD 7.0.1
- SuiteSparse from MacPorts.

The patch follows.

Cheers,
Anand


----------- patch -----------

diff -r 0fd458997533 scikits/sparse/cholmod.pyx
--- a/scikits/sparse/cholmod.pyx Thu May 05 11:16:24 2011 -0700
+++ b/scikits/sparse/cholmod.pyx Fri May 06 10:01:09 2011 +0100
@@ -46,7 +46,7 @@
hack.base = <void *> base
return arr

-cdef extern from "suitesparse/cholmod.h":
+cdef extern from "ufsparse/cholmod.h":
cdef enum:
CHOLMOD_INT
CHOLMOD_PATTERN, CHOLMOD_REAL, CHOLMOD_COMPLEX
diff -r 0fd458997533 setup.py
--- a/setup.py Thu May 05 11:16:24 2011 -0700
+++ b/setup.py Fri May 06 10:01:09 2011 +0100
@@ -70,11 +70,11 @@
ext_modules = [
Extension("scikits.sparse.cholmod",
["scikits/sparse/cholmod.pyx"],
- libraries=["cholmod"],
- include_dirs=[np.get_include()],
+
libraries=["cholmod","amd","camd","colamd","metis","ccolamd"],
+ include_dirs=[np.get_include(),'/opt/local/
include'],
# If your CHOLMOD is in a funny place, you
may need to
# add something like this:
- #library_dirs=["/opt/suitesparse/lib"],
+ library_dirs=["/opt/local/lib"]
# And modify include_dirs above in a similar
way.
),
],

------------- end of patch ----------------

>  https://code.google.com/p/scikits-sparse/source/detail?r=ad106e9c2c2d...


> (I believe it works -- it does compile -- but technically I can't
> guarantee it since for me the tests are now failing with an "illegal
> instruction" error inside BLAS. But I think this must be an unrelated
> Ubuntu screwup. Yay software.)
>
> And I'll see about poking Cython upstream to get this fixed...
>
> -- Nathaniel
> _______________________________________________
> SciPy-User mailing list

> SciPy-U...@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user

Reply all
Reply to author
Forward
0 new messages