Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pip install a cython module and make its pxds available for cimport?

Tags:

python

pip

cython

I'm trying to pip install a Cython library (https://github.com/kmike/marisa-trie/tree/master/src, for example) and then subclass it in Cython by cimporting from its pxds. Is there any way to make the related pxds from the library available to me so I can cimport from them? I've checked a bunch of related info in Cython docs like this, but all of it deals with the case where pxd files are available in relative folders and not pip installed somewhere.

like image 872
Eli Avatar asked Apr 26 '16 01:04

Eli


1 Answers

There is a "package_data" setting and associated settings you can add to setup.py, e.g.

setup(...,
      packages=['helpers']
      package_dir={'helpers': 'src/helpers'},
      package_data={'helpers': ['*.pxd']},
)

Check out: http://docs.cython.org/en/latest/src/userguide/sharing_declarations.html#search-paths-for-definition-files

and I've taken the example above from here: https://groups.google.com/forum/#!topic/cython-users/fYaqdkSfCI0

like image 196
jcdude Avatar answered Oct 28 '22 20:10

jcdude