3
votes

I am using cython for building an extension module. The module depends on an external shared library, which is found when the module is built. Further I have some pure Python modules in the same directory.

Can anybody give me an example setup.py for this task ? I have problems getting the extension module, the pure python module and the shared lib in the same directory when calling "python setup.py install".

1
Are you using Py2EXE for deployment, or just trying to make a binary installer for you package using python setup.py bdist_wininst? - fviktor
I just tried a local "python setup.py install" to get my stuff to .../site-packages/ - rocksportrocker

1 Answers

1
votes

I found a solution: I have a package dir ABC like

ABC/
    __init__.py
    A.py
    B.pyx
    C.so             (or C.dll and C.lib on win)

then the following setup.py does the job:

#input-encoding: utf-8
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
  name = "ABC",
  packages = ["ABC"],
  package_dir = { "ABC" : "." },
  ext_package = "ABC",
  cmdclass = {'build_ext': build_ext},
  package_data = { ".": [ "C.dll"] },
  ext_modules = [ Extension("B", sources="B.pyx", libraries="C" ) ]
)

I had to put setup.py in ABC/ and redirect via package_dir = { "ABC" : "." },