Background:
I've used SWIG to develop a Python wrapper for a C/C++ library.
Now I need to use setuptools
to package the project for distribution. The package needs to include the SWIG generated C extension and all DLL dependencies. My project directory looks like the following:
project_directory/
|
--- foo_mod/
| |
| --- __init__.py
|
--- libs/
| |
| --- lib_a.dll
| --- lib_b.dll
|
--- core.py (generated by SWIG)
--- core_wrap.cxx (generated by SWIG)
--- core_wrap.h
--- setup.py
What I have tried:
from setuptools import setup, find_packages, Extension
application_module = Extension(
'_core',
)
setup(
name='foo_mod',
version='0.1',
author="My Name",
email="my.name@company.com",
description="""Simple example""",
ext_modules=[application_module],
packages=find_packages(),
package_data={
"" : ['libs/*.dll']
},
py_modules=['core'],
python_requires='>=3.6')
Command to build the extension:
PS > python setup.py build_ext --build-lib .\foo_mod
Following this command, the python extension _core.pyd
is written to foo_mod\
.
Command to build the package:
PS > python setup.py sdist bdist_wheel
Problem:
The _core.pyd
extension and libs are not being included into the wheel.
Question: How do I properly include the library dependencies into the package?