开发者

Install mixture of extension module. pure python module and shared libraries with distutils

开发者 https://www.devze.com 2023-03-25 03:14 出处:网络
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 Pyth开发者_StackOverflow中文版on

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 Pyth开发者_StackOverflow中文版on 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".


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" : "." },

0

精彩评论

暂无评论...
验证码 换一张
取 消