How to include a shared C library in a Python package

前端 未结 2 1292
野的像风
野的像风 2020-12-25 08:43

I have a project depending on a shared library. To make it clear from the beginning: the shared library is a pure C library and not a Python library. For reasons of simplici

2条回答
  •  梦毁少年i
    2020-12-25 08:54

    You can create a Python package which includes shared libraries and works on (almost) any linux distro using manylinux.

    The goal of the manylinux project is to provide a convenient way to distribute binary Python extensions as wheels on Linux. This effort has produced PEP 513 which defines the manylinux1_x86_64 and manylinux1_i686 platform tags.

    The general procedure is:

    1. Build the external library and the Python package inside one of the docker containers provided by the manylinux team (see python-manylinux-demo)
    2. Run auditwheel repair to copy the external shared libraries that your package depends on into the Python wheel, setting the RPATH accordingly.

    See .travis.yml and build-wheels.sh in the python-manylinux-demo repo for an example.

提交回复
热议问题