Re: [Cython] setup.py refusing to run cython

2011-06-15 Thread Stefan Behnel

Lisandro Dalcin, 14.06.2011 21:39:

On 14 June 2011 16:20, Nathaniel Smith wrote:

Hello Cython folks,

This message (see below) is the second report I've gotten of a very
strange build problem with a cython module. I'm just using the
standard 'from Cython.Distutils import build_ext', 'cmdclass =
{"build_ext": build_ext}' incantation, but for some reason setup.py is
attempting to just run gcc directly without calling cython first to
generate the .c file.

You can see the setup.py here:
  
https://code.google.com/p/scikits-sparse/source/browse/setup.py?name=scikits.sparse-0.1

Anyone have any ideas?


Your setup.py is mixing setuptools and Cython.Distutils. Both are
monkeypatching distutils, and in general that's a very bad idea.


Specifically, "setuptools" checks the list of source files and when it sees 
a .pyx extension, it checks if Pyrex (!) is installed. If not, which is 
rather unlikely for Cython users, it changes the file extension to ".c", 
thus preventing Cython from compiling it.


There are two ways around this. The ugly way is to put a fake Pyrex into 
sys.path during installation, e.g.


https://github.com/lxml/lxml/tree/master/fake_pyrex

A better way is to switch from "setuptools" to "distribute".

Stefan
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] setup.py refusing to run cython

2011-06-15 Thread Nathaniel Smith
On Wed, Jun 15, 2011 at 12:18 AM, Stefan Behnel  wrote:
> Lisandro Dalcin, 14.06.2011 21:39:
>>
>> On 14 June 2011 16:20, Nathaniel Smith wrote:
>>>
>>> Hello Cython folks,
>>>
>>> This message (see below) is the second report I've gotten of a very
>>> strange build problem with a cython module. I'm just using the
>>> standard 'from Cython.Distutils import build_ext', 'cmdclass =
>>> {"build_ext": build_ext}' incantation, but for some reason setup.py is
>>> attempting to just run gcc directly without calling cython first to
>>> generate the .c file.
>>>
>>> You can see the setup.py here:
>>>
>>>  https://code.google.com/p/scikits-sparse/source/browse/setup.py?name=scikits.sparse-0.1
>>>
>>> Anyone have any ideas?
>>
>> Your setup.py is mixing setuptools and Cython.Distutils. Both are
>> monkeypatching distutils, and in general that's a very bad idea.
>
> Specifically, "setuptools" checks the list of source files and when it sees
> a .pyx extension, it checks if Pyrex (!) is installed. If not, which is
> rather unlikely for Cython users, it changes the file extension to ".c",
> thus preventing Cython from compiling it.
>
> There are two ways around this. The ugly way is to put a fake Pyrex into
> sys.path during installation, e.g.
>
> https://github.com/lxml/lxml/tree/master/fake_pyrex

Right, I'm already doing that, and it works for me...but not for all
my users, I guess?

> A better way is to switch from "setuptools" to "distribute".

Right, I'd just switch to plain distutils except this package uses the
'scikits' namespace package, and IIUC distutils can't handle namespace
packages.

I'm finding the docs for 'distribute' a bit confusing, though. Is the
way that I switch from 'setuptools' to 'distribute' to just leave my
code the same, and tell my users to install distribute? That seems
kind of error prone...

-- Nathaniel
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


[Cython] Possible bug related to multiple assignment

2011-06-15 Thread Andrew Collette
Hi,

I ran into some odd behavior when working on my cython-based project
(h5py).  The following cython code snippet is the culprit ("priv" is a
function argument of type void**):

cdef conv_size_t *sizes
priv[0] = sizes = malloc(sizeof(conv_size_t))

gets turned into this (with Cython 0.14.1):

(__pyx_v_priv[0]) = ((__pyx_t_4h5py_5_conv_conv_size_t
*)malloc((sizeof(__pyx_t_4h5py_5_conv_conv_size_t;
__pyx_v_sizes = ((__pyx_t_4h5py_5_conv_conv_size_t
*)malloc((sizeof(__pyx_t_4h5py_5_conv_conv_size_t;

which leads to much head-scratching when one initializes "sizes", and
then later tries to recover that value via "priv".  Interestingly,
Cython 0.13 correctly initializes both priv[0] and sizes to the same
value:

  __pyx_t_5 = ((__pyx_t_4h5py_5_conv_conv_size_t
*)malloc((sizeof(__pyx_t_4h5py_5_conv_conv_size_t;
  (__pyx_v_priv[0]) = __pyx_t_5;
  __pyx_v_sizes = __pyx_t_5;

I wasn't able to find anything on this in the list archives or issue
tracker.  Right now I'm working around it by splitting the statement
into multiple lines:

   sizes =  malloc(sizeof(conv_size_t))
   priv[0] = sizes

Andrew
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel