Configure the location of the .so file created by Cython

I have a Cython package with C library wrappers. This is the tree structure of the package.

package/ _api.pxd _wrap.pyx setup.py wrapper/ __init__.py wrap.py 

Performance

 python setup.py build_ext --inplace 

places the _wrap.so file in the top-level directory of package/ , which is usually required in most cases. However, my wrap.py needs _wrap.so in the package/wrapper/ directory. I was wondering if there is a way to setup.py to create the .so file in the right place by itself without manually copying and pasting it into place.

+8
python cython wrapper
source share
1 answer

The output folder for the generated .so files can be specified as the first argument to the setuptools.Extension function.

Here is an example of Cython extensions,

 from setuptools import setup, find_packages, Extension from Cython.Distutils import build_ext ext_modules=[ Extension("package.wrapper.wrap", # location of the resulting .so ["package/wrapper/wrap.pyx"],) ] setup(name='package', packages=find_packages(), cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules, ) 
+4
source share

All Articles