Using setuptools to create a cython package calling an external C library

后端 未结 1 665

I am trying to compile, install and run a package that we\'ll call myPackage. It contains a *.pyx file that calls the function fftw_set_timel

相关标签:
1条回答
  • It turns out setuptools has a module setuptools.extension.Extension which is used in the same way as the distutils.extension.Extension module .

    In the end, the setup.py file looks something like :

    from setuptools import setup, find_packages
    from setuptools.extension import Extension
    from Cython.Build import cythonize
    
    extensions = [
        Extension(
            "myPackage.myModule",
            ["myPackage/myModule.pyx"],
            include_dirs=['/some/path/to/include/'], # not needed for fftw unless it is installed in an unusual place
            libraries=['fftw3', 'fftw3f', 'fftw3l', 'fftw3_threads', 'fftw3f_threads', 'fftw3l_threads'],
            library_dirs=['/some/path/to/include/'], # not needed for fftw unless it is installed in an unusual place
        ),
    ]
    
    setup(
        name = "myPackage",
        packages = find_packages(),
        ext_modules = cythonize(extensions)
    )
    

    Here is an overview of my installation directory :

    .
    ├── MANIFEST.in
    ├── myPackage
    │   └── myModule.pyx
    ├── README.rst
    └── setup.py
    

    where myModule.pyx is the file that calls fftw_set_timelimit().

    MANIFEST.in contains :

    include myPackage/*.*
    

    and README.rst is a mere plain text file.

    0 讨论(0)
提交回复
热议问题