Reputation: 31
I have one *.pyx (Cython) source file in my package but it was not getting included in the source distribution when I ran:
$ python3 setup.py sdist
Therefore, I added a MANIFEST.in
file to include all *.pyx files. My package requirements specify Cython as a requirement: therefore all my users would have Cython installed. In other packages, I use pyximport:
import pyximport; pyximport.install(language_level=3)
from mycythonpackage.mycythonmodule import *
Now when I run sdist
I correctly see the *.pyx files packaged in the tarball. However, when I extract the tarball to a folder, and then execute:
$ sudo pip3 install .
The installation proceeds perfectly. But the pyx files were not installed and therefore, my package is unable to find the Cython module when I run it.
Just including/installing the pyx files in my package will solve my problem as I expect my users to run my package as is, and Cython will compile them on the fly. I do not want to compile/build the pyx files nor do I want/need to package the .so / .c / ... files. I just want the plain *.pyx files installed. How can I instruct pip to forcefully include/install the *.pyx files during installation?
Upvotes: 0
Views: 1172
Reputation: 31
I found the solution: modify the setup.py
file to include:
package_data = { 'mypackage': ['mycythonmodule-filename.pyx']},
include_package_data = True
Upvotes: 1