开发者

Python copy a DLL to site-packages on Windows

开发者 https://www.devze.com 2022-12-29 22:12 出处:网络
I am writing a python extension module that needs to link with a 开发者_如何学编程third-party DLL. How can I copy this DLL to the site-packages directory using distutils (i.e. in my setup.py file)?Put

I am writing a python extension module that needs to link with a 开发者_如何学编程third-party DLL. How can I copy this DLL to the site-packages directory using distutils (i.e. in my setup.py file)?


Put your DLL in the package_data argument of your setup() (see the Installing Package Data section of the distutils documentation for details).

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

import distutils.sysconfig

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号