忽略 py2exe 中的library.zip
我需要一个可执行文件(.exe),它从文件中获取一些参数,用户可以根据他/她的需要配置这些参数。由于我在 python 中创建了脚本,因此我使用 py2exe 来创建该可执行文件。虽然我可以放置一个名为 settings.dat 的可配置文件作为数据文件并使用它进行自定义,但我觉得如果可配置文件是 python 文件会更好(可以说settings.py)并使用它导入其中声明的变量。
因此,settings.py 不应包含在library.zip 中,我希望将其按原样包含并使其可由用户配置。这可能吗?
有没有办法避免创建library.zip并将所有依赖文件放在子文件夹中? (在这种情况下,我可以将settings.py放入其中,因为settings.pyc是从中派生的,对settings.py所做的任何更改都会得到反映)
I need to have an executable file (.exe) which takes some parameters from a file which can be configured by the user depending on his/her need. Since i have created scripts in python, i have used py2exe to create that executable. Though i could place a configurable file called settings.dat as data file and use it to customize, i feel it would be better if the configurable file is python file (lets say settings.py) and use it import the variables declared in it.
So settings.py shouldn't be included in library.zip and i would like it to be included as it is and make it configurable by user. Is this possible ?
Is there any way to avoid creating library.zip and just put all dependency files in a sub folder ? (In this case i can just put settings.py inside it, since settings.pyc is derived from it any changes made to settings.py will get reflected)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,将
skip_archive
选项设置为True
。http://www.py2exe.org/index.cgi/ListOfOptions
编辑: pyc文件放置在 zip 文件所在的同一文件夹中。
zipfile
关键字控制 zip 的路径。这会将文件放入子文件夹foo
中:Yes, set the
skip_archive
option toTrue
.http://www.py2exe.org/index.cgi/ListOfOptions
EDIT: The pyc files are placed in the same folder where the zip file would have been. The
zipfile
keyword controls the path to the zip. This puts the files in subfolderfoo
: