Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading