简体   繁体   中英

Basic setup.py - include the shared library

I am packaging a Python package with around 20 Python modules and one shared library[1]. I have create the following setup.py file:

from setuptools import setup, find_packages

setup(
    name = "mypack",
    version = "1.0",
    author = "Bill Coder",
    author_email = "bill.coder@email.com",
    description = ("My Code"),
    packages=find_packages(),
    long_description="Long description",
    )

And the filesystem looks like this:

mypack/
   __init__.py
   sub_pack1/
      __init__.py
      module1.py
      module2.py
   sub_pack2
      __init__.py
      moduleA.py
      shared_library.so

I have tried the commands:

bash% python -m build --wheel

and

bash% python setup.py bdist_wheel

in both cases a wheel package is assembled but the shared library mypack/subpack2/shared_library.so is not included in the final product.

[1]: The shared library comes from cythonize on a pyx file. Ideally I would like to build the extension as part of the setup.py - but for now I settle for the more moderate ambition of an external build process and then packaging everything up into a package which I can install myself. The purpose of the package is just to serve as a temporary step between CI and target - the package will not be published beyond that.

Add include_package_data=True to your setup.py.

You may need to include a MANIFEST.in file to your project root that points to the additional file:

include mypack/sub_pack2/shared_library.so

more about this here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM