[Pyrex] Help for public Python extension types.

Daehyok Shin sdhyok at gmail.com
Fri Jun 27 21:32:27 CEST 2008


One following up.
I found a web page of cython discusses the same problem.

http://wiki.cython.org/PackageHierarchy

So, I tried cython, rather than pyrexc for compiling, and then BOOM!
The problem is gone!
I am wondering why Pyrex forces users to use the complex name scheme
for extension types.
Anyway, I switched to cython.

Daehyok

On Fri, Jun 27, 2008 at 2:29 PM, Daehyok Shin <sdhyok at gmail.com> wrote:
> Thanks, Robert.
> Unfortunately, your suggestion did not work.
>
> I found the cause of the problem is the new syntax required for
> extension types under a package directory. The files work well even
> without the cimport statement if I test the files in a non-package
> directory. But, once I put the files under a package, the pyx file
> could not find its corresponding pxd file.
>
> I am not familiar with this topic because it is a new syntax required
> by a recent Pyrex version.
> So, let me ask again with a more specific question.
>
> If the class A is supposed to be imported as xxx.yyy.zzz.test.A,
> how should I change the source code in the files?
>
> Any comments will be appreciated.
>
> Daehyok
>
> On Fri, Jun 27, 2008 at 2:10 AM, Robert Bradshaw
> <robertwb at math.washington.edu> wrote:
>> On Jun 26, 2008, at 8:13 PM, Daehyok Shin wrote:
>>
>>> Hi. Let me ask about the public Python extension types.
>>> I created the following files (simplified than actual files) to enable
>>> both other Pyrex and C programs to access the variable i in the X
>>> extension type. But, I found the generated header file, test.h, does
>>> not contain the variable i in its declaration of X.
>>> Any idea about what's wrong in the files?  Right now, I am using Pyrex
>>> ver. 0.9.8.4.
>>> Thanks in advance.
>>>
>>> ---- test.pxd ----
>>> cdef public class X[object x_object, type x_type]:
>>>    cdef public int i
>>>
>>> ---  test.pyx -----
>>> cimport test
>>> cdef public class X[object x_object, type x_type]:
>>>    pass
>>
>> Here you're declaring a new class called X in your pyx file. What you want
>> to do is
>>
>>    from test cimport X
>>
>> or
>>
>>    cimport test # use test.X to refer to the class.
>>
>> - Robert
>>
>>
>
>
>
> --
> Daehyok Shin, PhD
> Geography Department
> University of North Carolina-Chapel Hill
> USA
>



-- 
Daehyok Shin, PhD
Geography Department
University of North Carolina-Chapel Hill
USA



More information about the Pyrex mailing list