On Sep 16, 2009, at 4:55 PM, Magnus Lie Hetland wrote:

> On Sep 16, 2009, at 22:50 , Magnus Lie Hetland wrote:
>
>> If I run
>>
>> $ cython foo.py
>>
>> the file foo.pxd in the same directory is evidently used. However, if
>> I build an extension with either just foo.py or both foo.py and
>> foo.pxd as sources, using Distutils, I get results that seem to
>> indicate that the pxd isn't used.
>
>
> After some fiddling, I've come to the conclusion that this was, most
> likely, a PEBKAC :->
>
> I started playing around with Cython's build_ext.py, I've find that
> the difference is between the following two versions of the compile
> command...
>
> This worked
>
>    result = cython_compile(source, options=options)
>
> This, for some reason, didn't:
>
>    result = cython_compile(source, options=options
>                            full_module_name=module_name)
>
> Now, I'd put the code in a package -- except I'd left out the
> __init__.py for now (which I'd gotten some warnings about, but I
> wasn't planning on doing any importing yet, so I thought it wouldn't
> matter; I was using a glob in my setup.py and didn't want to compile
> the init file). But as the module name was of the form foo.foo, I
> suspected this might be the problem ... and indeed it was.
>
> So, I guess, if I'd done it "by the book", and included the
> __init__.py file, it would have worked from the start. However I'd say
> the compile failed in a rather non-obvious way... (I.e., it actually
> did compile -- it just ignored the .pxd file...)

Glad you were able to figure it out. I'm not sure how we should  
detect this kind of error...

> Maybe I'm still missing something, but at least it seems to be working
> now :)
>
> (I'd still be interested in hints on how people organize the code for
> projects using pure Python mode, though -- so that some .py files get
> compiled while others get installed, and so forth.)

Me too. (In Sage we use .pyx files, and actually have a massive,  
custom setup.py.)

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to