简体   繁体   English

Python将DLL复制到Windows上的站点包

[英]Python copy a DLL to site-packages on Windows

I am writing a python extension module that needs to link with a third-party DLL. 我正在编写需要与第三方DLL链接的python扩展模块。 How can I copy this DLL to the site-packages directory using distutils (ie in my setup.py file)? 如何使用distutils(即在我的setup.py文件中)将此DLL复制到site-packages目录?

Put your DLL in the package_data argument of your setup() (see the Installing Package Data section of the distutils documentation for details). 将DLL放入setup()package_data参数中setup()有关详细信息,请参见distutils文档的“ 安装软件包数据”部分)。

If you need to put the DLL outside of the package directory , you can use the data_files option. 如果需要将DLL放在包目录之外,则可以使用data_files选项。 For example to put it in the site-packages directory: 例如,将其放在site-packages目录中:

import distutils.sysconfig

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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