8

如何将一个 Python 程序打包成 exe,同时又保留部分 Python 源码便于修改

 3 years ago
source link: https://www.v2ex.com/t/789775
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

如何将一个 Python 程序打包成 exe,同时又保留部分 Python 源码便于修改

  lynn0977 · 5 小时 16 分钟前 · 494 次点击
这个需求的目的是希望将一个项目的主体框架部分(不太需要被改动到)打包成 exe,同时包含各种依赖的库等,但是部分经常需要改动的代码还保留 python 源码的形式,exe 程序可以执行调用到这部分源码内容,这样的话既便于部署,又保持一定灵活性根据根据需求变化修改一些处理逻辑,是否有方法可以实现。
4 条回复    2021-07-15 22:53:27 +08:00

bigtan

bigtan   5 小时 6 分钟前

为什么不是留个配置文件?

YsHaNg

YsHaNg   4 小时 59 分钟前

用 setuptool 把库打包好.\setup.py install --user 安装成 exe cd 到其他 py 文件目录运行那个 exe

caisudong007

caisudong007   4 小时 54 分钟前 via iPhone

打包我不清楚,不过可以用 importlib 从指定目录下把 py 文件导入成模块 dict,你再从这里面找要用的扩展方法

jim9606

jim9606   1 小时 38 分钟前

用官方的 Windows embeddable package 改装。
将主体框架的包打包为 base.zip ,内容可为 py 或 pyc (参考官方的 python3x.zip 结构,不能包含 dll )放在目录内。
编辑 python3x._pth,将 base.zip 和可变源码包目录加进去。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK