让py2exe包含我的数据文件(例如include_package_data) [英] Having py2exe include my data files (like include_package_data)
问题描述
我有一个Python应用程序,该应用程序的某些子包中包含非Python数据文件.我一直在使用setup.py
中的include_package_data
选项在进行分发时自动包括所有这些文件.效果很好.
I have a Python app which includes non-Python data files in some of its subpackages. I've been using the include_package_data
option in my setup.py
to include all these files automatically when making distributions. It works well.
现在我开始使用py2exe.我希望它能看到我具有include_package_data=True
并包含所有文件.但事实并非如此.它仅将我的Python文件放入library.zip
中,因此我的应用程序无法正常工作.
Now I'm starting to use py2exe. I expected it to see that I have include_package_data=True
and to include all the files. But it doesn't. It puts only my Python files in the library.zip
, so my app doesn't work.
如何使py2exe包含我的数据文件?
How do I make py2exe include my data files?
推荐答案
我最终通过为py2exe提供选项skip_archive=True
解决了它.这导致它不将Python文件放在library.zip
中,而只是将它们放在普通文件中.然后,我使用data_files
将数据文件放在Python包中.
I ended up solving it by giving py2exe the option skip_archive=True
. This caused it to put the Python files not in library.zip
but simply as plain files. Then I used data_files
to put the data files right inside the Python packages.
这篇关于让py2exe包含我的数据文件(例如include_package_data)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!