29 Jan 2012 16:46
Re: Re: Installing just a .pxd with Distutils
Thomas Wiecki <thomas.wiecki <at> googlemail.com>
2012-01-29 15:46:59 GMT
2012-01-29 15:46:59 GMT
Hi,
there still seems to be an issue with importing the module. It works
fine when calling functions but complains that gsl is not cimported
when trying to use a gsl type.
cdef gsl.gsl_integration_workspace * W
Error compiling Cython file:
------------------------------------------------------------
...
return gsl.gsl_ran_gaussian_pdf(x, sigma) + mu
cdef double cdf_numerical(double x, double mu, double sigma):
cdef double alpha, result, error, expected
cdef gsl.gsl_integration_workspace * W
^
------------------------------------------------------------
integrate.pyx:15:9: 'gsl' is not a cimported module
The code in question lives here:
https://github.com/twiecki/CythonGSL/blob/master/examples/integrate.pyx
Any help would be appreciated.
Thanks,
Thomas
On Fri, Jan 13, 2012 at 10:27 AM, Thomas Wiecki
<thomas.wiecki <at> googlemail.com> wrote:
> Great, that seems to work. Thanks so much!
>
> Btw. I incorporated your commit now, so feel free to delete the fork
> if you like.
>
> On Fri, Jan 13, 2012 at 3:28 PM, Robert Kern <robert.kern <at> gmail.com> wrote:
>> On 1/13/12 2:05 PM, Robert Kern wrote:
>>>
>>> On 1/13/12 1:47 PM, Thomas Wiecki wrote:
>>>>
>>>> I tried that before, but neither work:
>>>>
>>>>>> cython example.pyx
>>>>
>>>>
>>>> Error compiling Cython file:
>>>> ------------------------------------------------------------
>>>> ...
>>>> cimport cython_gsl
>>>> ^
>>>> ------------------------------------------------------------
>>>>
>>>> example.pyx:1:8: 'cython_gsl.pxd' not found
>>>
>>>
>>> You would have to do "from cython_gsl import gsl_airy" or whatever module
>>> you
>>> actually wanted to use.
>>>
>>> If you fixed gsl.pxd to include the .pxd files instead of .pxi files, then
>>> you
>>> could also do "from cython_gsl import gsl" to get access to everything at
>>> once,
>>> which may be reasonable.
>>
>>
>> It looks like you have implicit dependencies between each of the separate
>> files, so that doesn't work out-of-box. You would have to update all of the
>> .pxd files to explicitly cimport their types from the other .pxd files that
>> define them.
>>
>> A simpler approach is to leave everything but gsl.pxd as .pxi:
>>
>> https://github.com/rkern/CythonGSL/tree/one-pxd
>>
>> Then you can do "from cython_gsl cimport gsl"
>>
>>
>> --
>> Robert Kern
>>
>> "I have come to believe that the whole world is an enigma, a harmless enigma
>> that is made terrible by our own mad attempt to interpret it as though it
>> had
>> an underlying truth."
>> -- Umberto Eco
>>
RSS Feed