Best way to package a Python library that includes a C shared library?

后端 未结 3 1500
名媛妹妹
名媛妹妹 2021-02-04 05:00

I have written a library whose main functionality is implemented in C (speed is critical), with a thin Python layer around it to deal with the ctypes nastiness.

3条回答
  •  借酒劲吻你
    2021-02-04 06:05

    Given that you followed the instructions on how to create Python extensions in C, you should just enlist the extension modules like in this documentation.
    So the setup.py script of your library should look like this:

    from distutils.core import setup, Extension
    setup(
       name='your_python_library',
       version='1.0',
       ext_modules=[Extension('your_c_extension', ['your_c_extension.c'])],
    )
    

    and distutils knows how to compile your extension to C shared library and moreover where to put it.

    Of course I have no further information about your library, so you probably want to add more arguments to setup(...) call.

提交回复
热议问题