[Pyrex] How to reuse pyrex functions?

Daniele Varrazzo daniele.varrazzo at gmail.com
Thu Jul 27 11:51:23 UTC 2006


Hello,

i am trying to declare Pyrex function in a module called "asn1" and use 
it in a module called "mdc". I can't put a function declaration in a 
.pyd file, so i must use a "cdef public". Anyway i can't make it work 
smoothly.

mdc now depends on asn1 on linking, but adding "asn1" to the "libraries" 
in setup.py makes the linker looking for an "libasn1.so" file, failing.

I solved the issue creating a symlink libasn1.so -> asn1.so. Is this the 
way the issue is to be solved? By now it's a raw solution: i had to 
manually add the build directory into the "library_dirs" and manually 
create the symlink there. On install i should create another symlink 
too. I could automate something banging against distutils, but I'd like 
to know if there is some different way to make the thing work.

Anyway the solution leads to different usage of objects imported from 
the library. Before adding the exported functions, in mdc files i used to:

     cimport asn1
     asn1.TypeA().Something()

where TypeA is in some ".pxd". But if i have an exported function with 
signature:

     cdef public int funcOnA(TypeA *)

then i have to:

     cimport asn1
     from asn1 cimport TypeA
     include "asn1.pxi"

or else syntax errors will be detected on asn1.pxi import. Then later, i 
can't refer to asn1.funcOnA, of course, and i must use imported types 
and functions in different ways.

The situation could be solved by allowing non-extern C function 
declarations in .pxd, as the docs say it will be possible in a bright 
future... I'm sorry if this is a Frequently Asked Request (i'm rather 
new in Pyrex, and just reading the mailing list for a few days): is such 
update planned or maybe lurking in some branch waiting for testing?

Thank you very much,

Daniele



More information about the Pyrex mailing list