Python copies DLL to site packages on Windows

I am writing a python extension module that should communicate with a third-party DLL. How to copy this DLL to the sites directory using distutils (i.e. in the setup.py file)?

+2
source share
1 answer

Put your DLL in the argument of package_datayours setup()(for more information, see Installing Package Data in the distutils documentation).

If you need to put the DLL outside the package directory, you can use the option data_files. For example, to put it in a directory site-packages:

import distutils.sysconfig

setup(
    # [...]
    data_files = [(distutils.sysconfig.get_python_lib(), ["/path/to/the/DLL"])],
)
+1
source

Source: https://habr.com/ru/post/1612266/


All Articles