[Cython] BUG?: __init__.py file messing up .pxd detection!!!

Brian Granger ellisonbg.net at gmail.com
Thu Jun 19 03:17:20 CEST 2008


All the files are in $HOME/temp and I don't have an __init__.py file in $HOME.

In [165]: pwd
Out[165]: '/Users/bgranger'

In [166]: ls temp
__init__.py	shrubbing.c	shrubbing.pxd	shrubbing.pyx

In my real code though I do have an __init__.py in the .. dir.

Thanks for the quick reply!  Let me know if I can help in any way as I
need to get this one figured out quickly.

Brian


On Wed, Jun 18, 2008 at 7:14 PM, Robert Bradshaw
<robertwb at math.washington.edu> wrote:
> Is there an __init__ file the next level up?
>
> On Jun 18, 2008, at 6:11 PM, Brian Granger wrote:
>
>> HI,
>>
>> I am running cython-devel and have defined a simple extension type.  I
>> am finding that:
>>
>> IF:  there is a __init__.py file in the same directory as my pxd
>> and pyx file
>>
>> THEN: the pxd file is not processed and my extension type won't have
>> any attributes defined in the C code
>>
>> This reproduces my problem:
>>
>> $ cat shrubbing.pxd
>> cdef class Shrubbery:
>>     cdef int width
>>     cdef int length
>>
>> $ cat shrubbing.pyx
>> cdef class Shrubbery:
>>     def __new__(self, int w, int l):
>>         self.width = w
>>         self.length = l
>>
>> $ ls
>> __init__.py   shrubbing.pxd   shrubbing.pyx
>> $ cython shrubbing.pyx
>>
>> This is what shrubbing.c has for the extension type struct:
>>
>> struct __pyx_obj_4temp_9shrubbing_Shrubbery {
>>   PyObject_HEAD
>> };
>>
>> Notice, there are no attributes!!!!
>>
>> But not if I do:
>>
>> $ rm __init__.py
>> $ ls
>> shrubbing.c   shrubbing.pxd   shrubbing.pyx
>> $ cython shrubbing.pyx
>>
>> I get the attributes in the extension type:
>>
>> struct __pyx_obj_9shrubbing_Shrubbery {
>>   PyObject_HEAD
>>   int width;
>>   int length;
>> };
>>
>> I don't see how I could be doing something wrong.  I swear this code
>> was working just the other day (this is not really my code, but it
>> does the same thing).  The crazy thing is that I know sage uses
>> __init__.py files in directories that have pxd and pyx files just like
>> I am doing.
>>
>> Brian
>> _______________________________________________
>> Cython-dev mailing list
>> Cython-dev at codespeak.net
>> http://codespeak.net/mailman/listinfo/cython-dev
>
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/cython-dev
>


More information about the Cython-dev mailing list