本文介绍了在Py2exe构建中包含PYD / DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的一个模块使用.pyd文件中的函数。有一个选项可以排除dll(exclude_dlls),但是有没有包含它们?构建过程似乎不复制我的模块中的.pyd,尽管复制了其余的文件(.py)。我也需要包括一个.dll。如何让py2exe包含.pyd和.dll文件?

One of the modules for my app uses functions from a .pyd file. There's an option to exclude dlls (exclude_dlls) but is there one for including them? The build process doesn't seem to be copying the .pyd in my module despite copying the rest of the files (.py). I also need to include a .dll. How do I get py2exe to include both .pyd and .dll files?

推荐答案

.pyd和.DLL在这里是不同的,一个.pyd应该由modulefinder自动发现,如此包含(只要你有适当的import语句),而不需要做任何事情。如果有人错过了,你可以做同样的事情,如果.py文件被错过(他们只是模块):对于py2exe选项使用include选项。

.pyd's and .DLL's are different here, in that a .pyd ought to be automatically found by modulefinder and so included (as long as you have the appropriate "import" statement) without needing to do anything. If one is missed, you do the same thing as if a .py file was missed (they're both just modules): use the "include" option for the py2exe options.

Modulefinder不一定会查找依赖于.DLL(py2exe可以检测到一些),因此您可能需要使用'data_files'选项明确地包含这些。

Modulefinder will not necessarily find dependencies on .DLLs (py2exe can detect some), so you may need to explicitly include these, with the 'data_files' option.

例如,您有两个.DLL('foo.dll'和'bar.dll')包含在内,并将三个.pyd('module1.pyd','module2.pyd'和'module3.pyd')添加到包括:

For example, where you had two .DLL's ('foo.dll' and 'bar.dll') to include, and three .pyd's ('module1.pyd', 'module2.pyd', and 'module3.pyd') to include:

setup(name='App',
      # other options,
      data_files=[('.', 'foo.dll'), ('.', 'bar.dll')],
      options = {"py2exe" : {"includes" : "module1,module2,module3"}}
     )

这篇关于在Py2exe构建中包含PYD / DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-20 06:15