忽略 py2exe 中的library.zip

发布于 2024-12-29 00:56:36 字数 440 浏览 5 评论 0原文

我需要一个可执行文件(.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2025-01-05 00:56:36

有什么方法可以避免创建library.zip并把所有的
子文件夹中的依赖文件?

是的,将 skip_archive 选项设置为 True

http://www.py2exe.org/index.cgi/ListOfOptions

编辑: pyc文件放置在 zip 文件所在的同一文件夹中。 zipfile 关键字控制 zip 的路径。这会将文件放入子文件夹 foo 中:

setup(  
    ...

    zipfile="foo/bar.zip", 
    options={"py2exe": {"skip_archive": True}})

Is there any way to avoid creating library.zip and just put all
dependency files in a sub folder ?

Yes, set the skip_archive option to True.

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 subfolder foo:

setup(  
    ...

    zipfile="foo/bar.zip", 
    options={"py2exe": {"skip_archive": True}})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文