简体   繁体   中英

pip not installing Cython source files

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?

I found the solution: modify the setup.py file to include:

package_data = { 'mypackage': ['mycythonmodule-filename.pyx']},
include_package_data = True

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM