在 py2exe 构建中包含 PYD/DLL
我的应用程序的模块之一使用 .pyd 文件中的函数。 有一个选项可以排除 dll (exclude_dlls),但是是否有一个选项可以包含它们? 尽管复制了其余文件(.py),但构建过程似乎并未复制我的模块中的 .pyd。 我还需要包含一个 .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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许您可以使用 setup() 的 data_files 选项:
data_files 应该是元组列表,其中每个元组包含:
这不会将文件放入library.zip中,这对于dll来说不应该是问题,但我不知道pyd文件。
Maybe you could use the data_files option to setup():
data_files should be a list of tuples, where each tuple contains:
This won't put the files into library.zip, which shouldn't be a problem for dlls, but I don't know about pyd files.
.pyd 和 .DLL 在这里有所不同,因为 .pyd 应该由 modulefinder 自动找到并包含在内(只要您有适当的“导入”语句),而不需要执行任何操作。 如果丢失了一个,您将执行与丢失 .py 文件相同的操作(它们都只是模块):使用 py2exe 选项的“include”选项。
Modulefinder 不一定会找到 .DLL 的依赖项(py2exe 可以检测到一些),因此您可能需要使用“data_files”选项显式包含这些依赖项。
例如,您有两个 .DLL(“foo.dll”和“bar.dll”)要包含,以及三个 .pyd(“module1.pyd”、“module2.pyd”和“module3.pyd”)要包含包括:
.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 will not necessarily find dependencies on .DLLs (py2exe can detect some), so you may need to explicitly include these, with the 'data_files' option.
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:
如果没有自动检测到它们,请尝试手动将它们复制到 py2exe 的临时构建目录中。 它们将包含在最终的可执行文件中。
If they're not being automatically detected, try manually copying them into py2exe's temporary build directory. They will be included in the final executable.
您可以修改安装脚本以显式复制文件:
等等……当然,可以修改以满足您的需要。
You can modify the setup script to copy the files explicitly:
etc... modify to suit your needs, of course.