pytoexe-gui 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. pytoexe_gui-1.1.0/CHANGELOG.md +50 -0
  2. pytoexe_gui-1.1.0/LICENSE +24 -0
  3. pytoexe_gui-1.1.0/MANIFEST.in +4 -0
  4. pytoexe_gui-1.1.0/PKG-INFO +296 -0
  5. pytoexe_gui-1.1.0/README.md +235 -0
  6. pytoexe_gui-1.1.0/pyproject.toml +66 -0
  7. pytoexe_gui-1.1.0/pytoexe/__init__.py +10 -0
  8. pytoexe_gui-1.1.0/pytoexe/__main__.py +182 -0
  9. pytoexe_gui-1.1.0/pytoexe/certificate.py +164 -0
  10. pytoexe_gui-1.1.0/pytoexe/config.py +36 -0
  11. pytoexe_gui-1.1.0/pytoexe/depscan.py +502 -0
  12. pytoexe_gui-1.1.0/pytoexe/diagnostics.py +212 -0
  13. pytoexe_gui-1.1.0/pytoexe/dialogs.py +128 -0
  14. pytoexe_gui-1.1.0/pytoexe/env_manager.py +459 -0
  15. pytoexe_gui-1.1.0/pytoexe/exeinfo.py +232 -0
  16. pytoexe_gui-1.1.0/pytoexe/packaging.py +700 -0
  17. pytoexe_gui-1.1.0/pytoexe/project.py +187 -0
  18. pytoexe_gui-1.1.0/pytoexe/ui.py +465 -0
  19. pytoexe_gui-1.1.0/pytoexe/utils.py +117 -0
  20. pytoexe_gui-1.1.0/pytoexe/validation.py +46 -0
  21. pytoexe_gui-1.1.0/pytoexe/web/Nunito-Light.ttf +0 -0
  22. pytoexe_gui-1.1.0/pytoexe/web/css/general.css +175 -0
  23. pytoexe_gui-1.1.0/pytoexe/web/css/main.css +369 -0
  24. pytoexe_gui-1.1.0/pytoexe/web/css/modal.css +62 -0
  25. pytoexe_gui-1.1.0/pytoexe/web/css/pytoexe.css +541 -0
  26. pytoexe_gui-1.1.0/pytoexe/web/favicon.ico +0 -0
  27. pytoexe_gui-1.1.0/pytoexe/web/img/chevron-square-up.svg +3 -0
  28. pytoexe_gui-1.1.0/pytoexe/web/img/moon.svg +1 -0
  29. pytoexe_gui-1.1.0/pytoexe/web/img/plus.svg +6 -0
  30. pytoexe_gui-1.1.0/pytoexe/web/img/remove.svg +6 -0
  31. pytoexe_gui-1.1.0/pytoexe/web/img/sun.svg +1 -0
  32. pytoexe_gui-1.1.0/pytoexe/web/index.html +392 -0
  33. pytoexe_gui-1.1.0/pytoexe/web/js/configuration.js +89 -0
  34. pytoexe_gui-1.1.0/pytoexe/web/js/constants.js +137 -0
  35. pytoexe_gui-1.1.0/pytoexe/web/js/environment.js +294 -0
  36. pytoexe_gui-1.1.0/pytoexe/web/js/i18n.js +94 -0
  37. pytoexe_gui-1.1.0/pytoexe/web/js/importExport.js +80 -0
  38. pytoexe_gui-1.1.0/pytoexe/web/js/initialise.js +159 -0
  39. pytoexe_gui-1.1.0/pytoexe/web/js/interface.js +365 -0
  40. pytoexe_gui-1.1.0/pytoexe/web/js/messages.js +61 -0
  41. pytoexe_gui-1.1.0/pytoexe/web/js/modal.js +190 -0
  42. pytoexe_gui-1.1.0/pytoexe/web/js/packaging.js +130 -0
  43. pytoexe_gui-1.1.0/pytoexe/web/js/properties.js +257 -0
  44. pytoexe_gui-1.1.0/pytoexe/web/js/staticEvents.js +268 -0
  45. pytoexe_gui-1.1.0/pytoexe/web/js/utils.js +61 -0
  46. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/PKG-INFO +296 -0
  47. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/SOURCES.txt +60 -0
  48. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/dependency_links.txt +1 -0
  49. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/entry_points.txt +3 -0
  50. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/not-zip-safe +1 -0
  51. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/requires.txt +8 -0
  52. pytoexe_gui-1.1.0/pytoexe_gui.egg-info/top_level.txt +1 -0
  53. pytoexe_gui-1.1.0/setup.cfg +4 -0
  54. pytoexe_gui-1.1.0/tests/test_certificate.py +78 -0
  55. pytoexe_gui-1.1.0/tests/test_compat.py +29 -0
  56. pytoexe_gui-1.1.0/tests/test_depscan.py +93 -0
  57. pytoexe_gui-1.1.0/tests/test_diagnostics.py +42 -0
  58. pytoexe_gui-1.1.0/tests/test_exeinfo.py +93 -0
  59. pytoexe_gui-1.1.0/tests/test_gate.py +80 -0
  60. pytoexe_gui-1.1.0/tests/test_packaging.py +78 -0
  61. pytoexe_gui-1.1.0/tests/test_project.py +70 -0
  62. pytoexe_gui-1.1.0/tests/test_utils.py +35 -0
@@ -0,0 +1,50 @@
1
+ # 更新日志
2
+
3
+ ## 1.1.0 (2026-11-29)
4
+
5
+ ### 新增
6
+
7
+ - **压缩包项目**:可直接上传 `.zip`,自动解压、定位根目录 `main.py`、拒绝缺入口/路径穿越/损坏包,并把项目资源文件自动 `--add-data` 打进去。
8
+ - **全自动打包环境**:去掉“打包环境 / 解释器”手动选择,选好脚本或压缩包后自动检测并创建 venv、安装 PyInstaller、扫描并安装项目依赖。
9
+ - **项目级依赖扫描**:扫描压缩包/目录内全部 `.py`,识别任意层级的本地模块与包;跨平台专属模块标记“平台跳过”。
10
+ - **依赖闸门**:同步后实际用 `find_spec` 验证每个模块能否导入;依赖未就绪时界面禁用“开始打包”,后端与 CLI 同样拒绝打包并说明缺什么。
11
+ - **证书强制校验**:启用签名必须上传 `.pfx/.p12`,解析校验证书/私钥/密码/有效期;文件格式错误、密码错误、证书过期都会在打包前拦截。时间戳服务器改为可选(留空不加时间戳)。
12
+ - **首次使用说明**:界面内置首次使用引导与完整说明弹窗,并新增 `docs/使用说明.md`。
13
+ - 压缩包项目默认使用压缩包名作为程序名(不再叫 `main`)。
14
+
15
+ ### 修复
16
+
17
+ - 修复证书模块与配置变量同名导致的 `NameError`。
18
+ - 修复证书时间字段在新版 cryptography 下的弃用告警。
19
+ - 修复依赖表只显示宿主环境版本、无法反映虚拟环境安装情况的问题。
20
+ - 修复证书闸门会错误清除“依赖已就绪”状态的问题。
21
+
22
+ ## 1.0.0 (2026-11-29)
23
+
24
+ 首个正式版本,by ETC。
25
+
26
+ ### 新增
27
+
28
+ - 全中文界面:主界面、提示、错误信息,以及 PyInstaller 全部高级参数(约 40 项)的中文名称与说明。
29
+ - 内置虚拟打包环境:自动创建 venv、安装匹配版本的 PyInstaller,并可选择系统中的 Python 3.8 ~ 3.14。
30
+ - 自动依赖检测:递归扫描项目 `import`,区分标准库 / 项目本地模块 / 第三方库,并把导入名映射为发行包名。
31
+ - 依赖自动修复:缺失安装、版本纠正、重复提供同一模块的包清理、`pip check` 冲突修复。
32
+ - 程序属性面板:产品名称、文件描述、公司、版权、产品版本、文件版本、内部名称、原始文件名、商标、备注,生成 Windows 版本信息资源。
33
+ - 代码签名:支持 `.pfx / .p12` 证书 + 时间戳,Windows 使用 signtool、Linux/macOS 使用 osslsigncode。
34
+ - 打包后分发:ZIP 分发包、SHA256 校验文件、中文使用说明。
35
+ - 中文错误诊断:解析 PyInstaller/pip 日志,定位出错文件与行号,给出处理建议,并弹出错误窗口;完整日志落盘。
36
+ - 命令行模式:`pytoexe --cli`、`pytoexe --doctor`,便于自动化与自检。
37
+ - 结果卡片:展示产物路径、体积、耗时、依赖变更、分发文件,可一键打开。
38
+
39
+ ### 修复(相对上游)
40
+
41
+ - 修复高级选项中下拉框回填值判断错误(`indexOf(value) !== 1`)。
42
+ - 修复输出日志逐行设置高度导致的卡顿(改为合并刷新 + 上限截断)。
43
+ - 修复 Windows 下找不到 Chrome/Edge 时的启动分支问题。
44
+ - 修复打包失败时只显示英文 traceback、没有可读原因的问题。
45
+ - 修复打包过程中重复安装 / 版本冲突导致产物缺少依赖的问题。
46
+
47
+ ### 兼容性
48
+
49
+ - Python 3.8 ~ 3.14,Windows / Linux / macOS。
50
+ - PyInstaller >= 5.8。
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ETC
4
+
5
+ 本项目基于 auto-py-to-exe 二次开发,原始作品版权声明如下:
6
+ Copyright (c) 2023 Brent Vollebregt
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include README.md
3
+ include CHANGELOG.md
4
+ recursive-include pytoexe/web *
@@ -0,0 +1,296 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytoexe-gui
3
+ Version: 1.1.0
4
+ Summary: 把 Python 脚本或项目压缩包打包成可执行程序的中文图形工具:全自动虚拟环境与依赖安装、依赖闸门、程序属性/版权/证书校验与签名、打包后分发,by ETC
5
+ Author-email: ETC <et2416444244@outlook.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 ETC
9
+
10
+ 本项目基于 auto-py-to-exe 二次开发,原始作品版权声明如下:
11
+ Copyright (c) 2023 Brent Vollebregt
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+ Project-URL: Homepage, https://github.com/ETQWFD/pytoexe
32
+ Project-URL: Repository, https://github.com/ETQWFD/pytoexe
33
+ Project-URL: Bug Tracker, https://github.com/ETQWFD/pytoexe/issues
34
+ Project-URL: Changelog, https://github.com/ETQWFD/pytoexe/blob/main/CHANGELOG.md
35
+ Keywords: pyinstaller,exe,zip,gui,packaging,python,中文
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.8
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Operating System :: Microsoft :: Windows
45
+ Classifier: Operating System :: POSIX :: Linux
46
+ Classifier: Operating System :: MacOS
47
+ Classifier: Environment :: X11 Applications
48
+ Classifier: Topic :: Software Development :: Build Tools
49
+ Classifier: Natural Language :: Chinese (Simplified)
50
+ Requires-Python: >=3.8
51
+ Description-Content-Type: text/markdown
52
+ License-File: LICENSE
53
+ Requires-Dist: Eel!=0.18.0,>=0.11.0
54
+ Requires-Dist: pyinstaller>=5.8.0
55
+ Requires-Dist: requests>=2.25.0
56
+ Provides-Extra: dev
57
+ Requires-Dist: pytest>=7; extra == "dev"
58
+ Requires-Dist: build>=0.10; extra == "dev"
59
+ Requires-Dist: twine>=4; extra == "dev"
60
+ Dynamic: license-file
61
+
62
+ # pytoexe
63
+
64
+ **把 Python 脚本打包成可执行程序的中文图形工具 —— by ETC**
65
+
66
+ pytoexe 基于开源项目 [auto-py-to-exe](https://github.com/brentvollebregt/auto-py-to-exe)(MIT License)二次开发,
67
+ 保留了它成熟的 PyInstaller 参数体系,并针对“打包出来体积大、缺依赖、界面夹英文、改不了版权信息”这些痛点做了重写:
68
+
69
+ - **全自动虚拟打包环境**:不用手动选环境、选解释器。选了脚本或压缩包之后,pytoexe 自动检测 venv,没有就创建,自动装好 PyInstaller,再把项目依赖装进去。
70
+ - **项目压缩包上传**:除了单个 `.py`,还可以直接上传 `.zip`。压缩包根目录必须有 `main.py`(也支持“项目名/main.py”套一层文件夹),程序会自动解压、定位入口,并把资源文件一起打进去。
71
+ - **全项目依赖扫描 + 打包闸门**:扫描压缩包/项目目录里**所有** `.py` 的 `import`,把模块名映射成真正的发行包名,缺的自动安装、版本不对的纠正、重复提供同一模块或版本冲突的包自动删除;**依赖没装齐之前“开始打包”按钮是禁用的**,避免产物一运行就报 `ModuleNotFoundError`。
72
+ - **全中文界面**:从主界面到 PyInstaller 的每一个高级参数(约 40 项)都有中文名称和中文说明,不再出现半截英文。
73
+ - **程序属性 / 版权 / 证书签名**:新增“程序属性”面板,可写入产品名称、文件描述、公司、版权、产品版本、商标等 exe 资源;证书签名必须上传真实可解析的 `.pfx / .p12`(密码错误、格式不对、证书过期都会拦下),时间戳服务器可选。
74
+ - **打包后分发**:一键生成 ZIP 压缩包、SHA256 校验文件、`使用说明.txt`,直接发给别人即可。
75
+ - **中文错误诊断**:打包失败时自动解析 PyInstaller 日志,翻译成中文原因、定位到具体文件和行号、给出处理建议,并弹出窗口提示。
76
+ - **真实可用**:内置示例与测试,CI 覆盖 Python 3.8 ~ 3.13;打包产物会做启动验证。
77
+
78
+ > 命令行安装后直接输入 `pytoexe` 即可打开界面。
79
+
80
+ ## 界面预览
81
+
82
+ **压缩包项目:自动建环境、扫描全部代码、装齐依赖后按钮才可点**
83
+
84
+ ![压缩包自动准备](docs/screenshots/zip-ready.png)
85
+
86
+ **第一次使用说明:界面内置完整步骤,压缩包必须含 main.py 也写得很清楚**
87
+
88
+ ![首次使用说明](docs/screenshots/guide.png)
89
+
90
+ **依赖检测:自动区分标准库 / 项目本地模块 / 第三方库,并比较虚拟环境里的安装情况**
91
+
92
+ ![依赖检测](docs/screenshots/dependencies.png)
93
+
94
+ **打包成功:产物路径、体积、耗时、依赖变更与分发文件一目了然**
95
+
96
+ ![打包结果](docs/screenshots/result.png)
97
+
98
+ **打包失败:中文诊断 + 出错位置 + 处理建议弹窗**
99
+
100
+ ![错误弹窗](docs/screenshots/error.png)
101
+
102
+ **证书校验:只接受真实可用的 .pfx / .p12,证书有问题会直接拦住打包**
103
+
104
+ ![证书拦截](docs/screenshots/cert-block.png)
105
+
106
+ **程序属性:产品名称、版权、版本号、代码签名证书、自动分发,全部可填**
107
+
108
+ ![程序属性](docs/screenshots/properties.png)
109
+
110
+ **高级选项:PyInstaller 全部参数均为中文名称与中文说明**
111
+
112
+ ![高级选项](docs/screenshots/advanced.png)
113
+
114
+ ---
115
+
116
+ ## 安装
117
+
118
+ 方式一(推荐,立即可用):直接从 GitHub Release 安装
119
+
120
+ ```bash
121
+ pip install https://github.com/ETQWFD/pytoexe/releases/download/v1.1.0/pytoexe_gui-1.1.0-py3-none-any.whl
122
+ ```
123
+
124
+ 方式二:PyPI 发布后(`pytoexe-gui`)
125
+
126
+ ```bash
127
+ pip install pytoexe-gui
128
+ ```
129
+
130
+ > PyPI 上的 `pytoexe` 名称已被另一个无关项目占用,所以发行包名为 **pytoexe-gui**,
131
+ > 安装后的命令仍然是 **`pytoexe`** 和 `pytoexe-gui`。
132
+
133
+ 要求 Python **3.8 及以上**(已在 3.8 / 3.9 / 3.10 / 3.11 / 3.12 / 3.13 / 3.14 上适配)。
134
+
135
+ Linux 如果缺少图形库:
136
+
137
+ ```bash
138
+ sudo apt install python3-tk python3-venv
139
+ ```
140
+
141
+ ## 发布到 PyPI(维护者)
142
+
143
+ PyPI 上 `pytoexe` 已被另一个项目占用,本项目的发行名是 `pytoexe-gui`。首次发布二选一:
144
+
145
+ 1. **Trusted Publishing(推荐,无需 token)**
146
+ 在 https://pypi.org/manage/account/publishing/ 添加:
147
+ Owner `ETQWFD` / Repository `pytoexe` / Workflow `publish.yml` / Environment `pypi`。
148
+ 然后在 GitHub Actions 手动运行 `publish`,`confirm` 输入 `yes`。
149
+ 2. **API Token**
150
+ `PYPI_API_TOKEN=pypi-xxxx bash scripts/publish.sh`
151
+
152
+ ## 快速开始
153
+
154
+ ```bash
155
+ pytoexe
156
+ ```
157
+
158
+ 1. 在“脚本 / 项目压缩包”里选择 `.py` 脚本,或包含 `main.py` 的 `.zip`;
159
+ 2. 等下方自动准备完成:建环境 → 装 PyInstaller → 扫描全部代码 → 安装/修复依赖;
160
+ 3. 依赖齐了以后,“开始打包”按钮才会变成可点击(橙色提示会说明还缺什么);
161
+ 4. 选择“单文件 / 单目录”和“显示 / 隐藏控制台”;
162
+ 5. 需要版权、公司、版本号,就展开“程序属性 · 版权 · 证书签名”填写;需要签名就上传 `.pfx/.p12`;
163
+ 6. 点“开始打包”。成功后会显示产物大小、用时、依赖变更和分发文件;失败会弹出中文诊断。
164
+
165
+ 更完整的步骤、压缩包规则、证书要求和命令行示例见 [docs/使用说明.md](docs/使用说明.md)。
166
+
167
+ ## 内置虚拟打包环境(全自动)
168
+
169
+ - 默认目录:`~/.pytoexe/venv`(一般不用改;改目录后会自动重新准备)。
170
+ - **不需要手动选择环境或解释器**:自动使用当前运行的 Python 创建 venv,环境缺失就自动创建,自动安装 PyInstaller。
171
+ - 打包使用该环境里的 Python + PyInstaller 执行,所以“本机没装某个库”不会影响打包结果。
172
+ - 依赖检测覆盖整个项目:
173
+ - 单个 `.py`:扫描它所在目录的所有代码;
174
+ - `.zip`:解压后扫描压缩包内所有 `.py`;
175
+ - 标准库直接跳过;项目自带模块/包不当作第三方;其他映射为发行包名(如 `PIL → Pillow`、`cv2 → opencv-python`、`yaml → PyYAML`)。
176
+ - 同步策略:
177
+ 1. 缺失的包装进环境;
178
+ 2. 版本不一致的按项目实际依赖纠正;
179
+ 3. 同一个 import 名被多个包提供时,只保留需要的那个;
180
+ 4. 执行 `pip check`,把不匹配又不需要的包移除,需要的升级到满足要求的版本;
181
+ 5. 其他平台专属模块(如 `win32api` 在 Linux)标记为“平台跳过”,不会硬装失败。
182
+ - **依赖闸门**:同步后还会在虚拟环境里用 `find_spec` 实际验证每个模块能否导入,仍有缺失就不允许打包。
183
+
184
+ ## 程序属性与证书签名
185
+
186
+ “程序属性”会生成 PyInstaller 的 `--version-file`,写入 exe 的“属性 → 详细信息”:
187
+
188
+ | 字段 | 对应资源名 |
189
+ | --- | --- |
190
+ | 产品名称 | ProductName |
191
+ | 文件描述 | FileDescription |
192
+ | 公司 / 作者 | CompanyName |
193
+ | 版权信息 | LegalCopyright |
194
+ | 产品版本 / 文件版本 | ProductVersion / FileVersion |
195
+ | 内部名称 | InternalName |
196
+ | 原始文件名 | OriginalFilename |
197
+ | 商标声明 | LegalTrademarks |
198
+ | 备注 | Comments |
199
+
200
+ - 版本信息只对 **Windows exe** 生效,其它系统会自动跳过并给出提示。
201
+ - 证书签名:Windows 调用 `signtool`(Windows SDK 自带),Linux/macOS 调用 `osslsigncode`。
202
+ - 证书必须上传 `.pfx / .p12`,打包前会解析校验证书与私钥、密码和有效期;不合格会直接拒绝打包。
203
+ - 时间戳服务器可选:留空则不添加时间戳;填写则使用该地址做 RFC3161 时间戳。
204
+ - 没有安装签名工具时不会中断打包,而是在结果里给出中文提示(证书本身仍会先校验)。
205
+
206
+ ## 打包后分发
207
+
208
+ 勾选“打包后分发”后会在输出目录生成:
209
+
210
+ - `程序名-版本-平台.zip`:可直接分发的压缩包;
211
+ - `SHA256SUMS.txt`:完整性校验值;
212
+ - `使用说明.txt`:运行方式、版权、校验方法。
213
+
214
+ ## 命令行用法
215
+
216
+ ```bash
217
+ # 环境自检(Python、虚拟环境、PyInstaller、可用解释器)
218
+ pytoexe --doctor
219
+
220
+ # 无界面直接打包(适合 CI)
221
+ pytoexe --cli main.py --onefile --windowed --name MyTool --bundle \
222
+ --product-name "我的工具" --company "ETC" \
223
+ --copyright "Copyright © 2026 ETC" --version-string 1.2.3.0
224
+
225
+ # 打包项目压缩包(自动解压、找 main.py、带上资源文件)
226
+ pytoexe --cli 项目.zip --onefile --bundle --output-dir dist
227
+
228
+ # 不用内置环境,改用当前 Python(不推荐)
229
+ pytoexe --cli main.py --no-venv
230
+ ```
231
+
232
+ ## 出错时会发生什么
233
+
234
+ 打包失败后会自动做这些事:
235
+
236
+ 1. 从日志里找出异常类型、模块名、出错文件和行号;
237
+ 2. 翻译成中文原因(例如 “缺少 Python 模块:pandas”“位数不匹配”“没有写入权限”);
238
+ 3. 给出针对性的处理建议;
239
+ 4. 弹出“打包出错”窗口,展示原因、出错位置、建议,并提供“复制完整诊断”“打开日志文件”;
240
+ 5. 完整日志同时写入 `~/.pytoexe/logs/`。
241
+
242
+ ## 兼容性
243
+
244
+ - Python 3.8 ~ 3.14
245
+ - Windows / Linux / macOS
246
+ - PyInstaller 5.8 及以上(Python 3.8 环境会自动选择 5.x/6.x 兼容版本)
247
+ - 界面基于 Eel,需要 Chrome / Edge 或系统默认浏览器
248
+
249
+ ## 开发
250
+
251
+ ```bash
252
+ git clone https://github.com/ETQWFD/pytoexe.git
253
+ cd pytoexe
254
+ pip install -e ".[dev]"
255
+ pytest
256
+ python -m pytoexe
257
+ ```
258
+
259
+ 构建发行包:
260
+
261
+ ```bash
262
+ python -m build
263
+ twine check dist/*
264
+
265
+ # 发布到 PyPI(需要先在 pypi.org 创建 API Token)
266
+ PYPI_API_TOKEN=pypi-xxxx bash scripts/publish.sh
267
+ ```
268
+
269
+ > 如果 PyPI 上出现 CalledSetup 错误,说明该版本号已存在,修改 `pyproject.toml` 里的 version 后重新构建即可。
270
+
271
+ ## 目录结构
272
+
273
+ ```
274
+ pytoexe/
275
+ ├── pytoexe/
276
+ │ ├── __main__.py # 入口(GUI / CLI / doctor)
277
+ │ ├── packaging.py # 打包主流程(依赖闸门、证书、分发)
278
+ │ ├── project.py # .py / .zip 项目准备(main.py 定位、资源收集)
279
+ │ ├── certificate.py # .pfx/.p12 证书校验
280
+ │ ├── env_manager.py # 虚拟环境创建、依赖同步与清理
281
+ │ ├── depscan.py # import 扫描与模块→发行包映射
282
+ │ ├── exeinfo.py # 版本信息资源生成、证书签名
283
+ │ ├── diagnostics.py # 英文报错 → 中文诊断
284
+ │ ├── ui.py # Eel 后端接口
285
+ │ └── web/ # 全中文界面(HTML/CSS/JS)
286
+ ├── examples/ # 可直接打包的示例
287
+ ├── tests/ # 单元测试
288
+ └── .github/workflows/ # 测试与发布流水线
289
+ ```
290
+
291
+ ## 致谢与许可
292
+
293
+ - 本项目基于 **auto-py-to-exe**(Copyright © 2018 Brent Vollebregt,MIT License)二次开发,
294
+ 原始版权声明保留在 `LICENSE` 中。
295
+ - 打包引擎为 [PyInstaller](https://pyinstaller.org/)。
296
+ - 本项目同样使用 MIT License,作者 **by ETC**。
@@ -0,0 +1,235 @@
1
+ # pytoexe
2
+
3
+ **把 Python 脚本打包成可执行程序的中文图形工具 —— by ETC**
4
+
5
+ pytoexe 基于开源项目 [auto-py-to-exe](https://github.com/brentvollebregt/auto-py-to-exe)(MIT License)二次开发,
6
+ 保留了它成熟的 PyInstaller 参数体系,并针对“打包出来体积大、缺依赖、界面夹英文、改不了版权信息”这些痛点做了重写:
7
+
8
+ - **全自动虚拟打包环境**:不用手动选环境、选解释器。选了脚本或压缩包之后,pytoexe 自动检测 venv,没有就创建,自动装好 PyInstaller,再把项目依赖装进去。
9
+ - **项目压缩包上传**:除了单个 `.py`,还可以直接上传 `.zip`。压缩包根目录必须有 `main.py`(也支持“项目名/main.py”套一层文件夹),程序会自动解压、定位入口,并把资源文件一起打进去。
10
+ - **全项目依赖扫描 + 打包闸门**:扫描压缩包/项目目录里**所有** `.py` 的 `import`,把模块名映射成真正的发行包名,缺的自动安装、版本不对的纠正、重复提供同一模块或版本冲突的包自动删除;**依赖没装齐之前“开始打包”按钮是禁用的**,避免产物一运行就报 `ModuleNotFoundError`。
11
+ - **全中文界面**:从主界面到 PyInstaller 的每一个高级参数(约 40 项)都有中文名称和中文说明,不再出现半截英文。
12
+ - **程序属性 / 版权 / 证书签名**:新增“程序属性”面板,可写入产品名称、文件描述、公司、版权、产品版本、商标等 exe 资源;证书签名必须上传真实可解析的 `.pfx / .p12`(密码错误、格式不对、证书过期都会拦下),时间戳服务器可选。
13
+ - **打包后分发**:一键生成 ZIP 压缩包、SHA256 校验文件、`使用说明.txt`,直接发给别人即可。
14
+ - **中文错误诊断**:打包失败时自动解析 PyInstaller 日志,翻译成中文原因、定位到具体文件和行号、给出处理建议,并弹出窗口提示。
15
+ - **真实可用**:内置示例与测试,CI 覆盖 Python 3.8 ~ 3.13;打包产物会做启动验证。
16
+
17
+ > 命令行安装后直接输入 `pytoexe` 即可打开界面。
18
+
19
+ ## 界面预览
20
+
21
+ **压缩包项目:自动建环境、扫描全部代码、装齐依赖后按钮才可点**
22
+
23
+ ![压缩包自动准备](docs/screenshots/zip-ready.png)
24
+
25
+ **第一次使用说明:界面内置完整步骤,压缩包必须含 main.py 也写得很清楚**
26
+
27
+ ![首次使用说明](docs/screenshots/guide.png)
28
+
29
+ **依赖检测:自动区分标准库 / 项目本地模块 / 第三方库,并比较虚拟环境里的安装情况**
30
+
31
+ ![依赖检测](docs/screenshots/dependencies.png)
32
+
33
+ **打包成功:产物路径、体积、耗时、依赖变更与分发文件一目了然**
34
+
35
+ ![打包结果](docs/screenshots/result.png)
36
+
37
+ **打包失败:中文诊断 + 出错位置 + 处理建议弹窗**
38
+
39
+ ![错误弹窗](docs/screenshots/error.png)
40
+
41
+ **证书校验:只接受真实可用的 .pfx / .p12,证书有问题会直接拦住打包**
42
+
43
+ ![证书拦截](docs/screenshots/cert-block.png)
44
+
45
+ **程序属性:产品名称、版权、版本号、代码签名证书、自动分发,全部可填**
46
+
47
+ ![程序属性](docs/screenshots/properties.png)
48
+
49
+ **高级选项:PyInstaller 全部参数均为中文名称与中文说明**
50
+
51
+ ![高级选项](docs/screenshots/advanced.png)
52
+
53
+ ---
54
+
55
+ ## 安装
56
+
57
+ 方式一(推荐,立即可用):直接从 GitHub Release 安装
58
+
59
+ ```bash
60
+ pip install https://github.com/ETQWFD/pytoexe/releases/download/v1.1.0/pytoexe_gui-1.1.0-py3-none-any.whl
61
+ ```
62
+
63
+ 方式二:PyPI 发布后(`pytoexe-gui`)
64
+
65
+ ```bash
66
+ pip install pytoexe-gui
67
+ ```
68
+
69
+ > PyPI 上的 `pytoexe` 名称已被另一个无关项目占用,所以发行包名为 **pytoexe-gui**,
70
+ > 安装后的命令仍然是 **`pytoexe`** 和 `pytoexe-gui`。
71
+
72
+ 要求 Python **3.8 及以上**(已在 3.8 / 3.9 / 3.10 / 3.11 / 3.12 / 3.13 / 3.14 上适配)。
73
+
74
+ Linux 如果缺少图形库:
75
+
76
+ ```bash
77
+ sudo apt install python3-tk python3-venv
78
+ ```
79
+
80
+ ## 发布到 PyPI(维护者)
81
+
82
+ PyPI 上 `pytoexe` 已被另一个项目占用,本项目的发行名是 `pytoexe-gui`。首次发布二选一:
83
+
84
+ 1. **Trusted Publishing(推荐,无需 token)**
85
+ 在 https://pypi.org/manage/account/publishing/ 添加:
86
+ Owner `ETQWFD` / Repository `pytoexe` / Workflow `publish.yml` / Environment `pypi`。
87
+ 然后在 GitHub Actions 手动运行 `publish`,`confirm` 输入 `yes`。
88
+ 2. **API Token**
89
+ `PYPI_API_TOKEN=pypi-xxxx bash scripts/publish.sh`
90
+
91
+ ## 快速开始
92
+
93
+ ```bash
94
+ pytoexe
95
+ ```
96
+
97
+ 1. 在“脚本 / 项目压缩包”里选择 `.py` 脚本,或包含 `main.py` 的 `.zip`;
98
+ 2. 等下方自动准备完成:建环境 → 装 PyInstaller → 扫描全部代码 → 安装/修复依赖;
99
+ 3. 依赖齐了以后,“开始打包”按钮才会变成可点击(橙色提示会说明还缺什么);
100
+ 4. 选择“单文件 / 单目录”和“显示 / 隐藏控制台”;
101
+ 5. 需要版权、公司、版本号,就展开“程序属性 · 版权 · 证书签名”填写;需要签名就上传 `.pfx/.p12`;
102
+ 6. 点“开始打包”。成功后会显示产物大小、用时、依赖变更和分发文件;失败会弹出中文诊断。
103
+
104
+ 更完整的步骤、压缩包规则、证书要求和命令行示例见 [docs/使用说明.md](docs/使用说明.md)。
105
+
106
+ ## 内置虚拟打包环境(全自动)
107
+
108
+ - 默认目录:`~/.pytoexe/venv`(一般不用改;改目录后会自动重新准备)。
109
+ - **不需要手动选择环境或解释器**:自动使用当前运行的 Python 创建 venv,环境缺失就自动创建,自动安装 PyInstaller。
110
+ - 打包使用该环境里的 Python + PyInstaller 执行,所以“本机没装某个库”不会影响打包结果。
111
+ - 依赖检测覆盖整个项目:
112
+ - 单个 `.py`:扫描它所在目录的所有代码;
113
+ - `.zip`:解压后扫描压缩包内所有 `.py`;
114
+ - 标准库直接跳过;项目自带模块/包不当作第三方;其他映射为发行包名(如 `PIL → Pillow`、`cv2 → opencv-python`、`yaml → PyYAML`)。
115
+ - 同步策略:
116
+ 1. 缺失的包装进环境;
117
+ 2. 版本不一致的按项目实际依赖纠正;
118
+ 3. 同一个 import 名被多个包提供时,只保留需要的那个;
119
+ 4. 执行 `pip check`,把不匹配又不需要的包移除,需要的升级到满足要求的版本;
120
+ 5. 其他平台专属模块(如 `win32api` 在 Linux)标记为“平台跳过”,不会硬装失败。
121
+ - **依赖闸门**:同步后还会在虚拟环境里用 `find_spec` 实际验证每个模块能否导入,仍有缺失就不允许打包。
122
+
123
+ ## 程序属性与证书签名
124
+
125
+ “程序属性”会生成 PyInstaller 的 `--version-file`,写入 exe 的“属性 → 详细信息”:
126
+
127
+ | 字段 | 对应资源名 |
128
+ | --- | --- |
129
+ | 产品名称 | ProductName |
130
+ | 文件描述 | FileDescription |
131
+ | 公司 / 作者 | CompanyName |
132
+ | 版权信息 | LegalCopyright |
133
+ | 产品版本 / 文件版本 | ProductVersion / FileVersion |
134
+ | 内部名称 | InternalName |
135
+ | 原始文件名 | OriginalFilename |
136
+ | 商标声明 | LegalTrademarks |
137
+ | 备注 | Comments |
138
+
139
+ - 版本信息只对 **Windows exe** 生效,其它系统会自动跳过并给出提示。
140
+ - 证书签名:Windows 调用 `signtool`(Windows SDK 自带),Linux/macOS 调用 `osslsigncode`。
141
+ - 证书必须上传 `.pfx / .p12`,打包前会解析校验证书与私钥、密码和有效期;不合格会直接拒绝打包。
142
+ - 时间戳服务器可选:留空则不添加时间戳;填写则使用该地址做 RFC3161 时间戳。
143
+ - 没有安装签名工具时不会中断打包,而是在结果里给出中文提示(证书本身仍会先校验)。
144
+
145
+ ## 打包后分发
146
+
147
+ 勾选“打包后分发”后会在输出目录生成:
148
+
149
+ - `程序名-版本-平台.zip`:可直接分发的压缩包;
150
+ - `SHA256SUMS.txt`:完整性校验值;
151
+ - `使用说明.txt`:运行方式、版权、校验方法。
152
+
153
+ ## 命令行用法
154
+
155
+ ```bash
156
+ # 环境自检(Python、虚拟环境、PyInstaller、可用解释器)
157
+ pytoexe --doctor
158
+
159
+ # 无界面直接打包(适合 CI)
160
+ pytoexe --cli main.py --onefile --windowed --name MyTool --bundle \
161
+ --product-name "我的工具" --company "ETC" \
162
+ --copyright "Copyright © 2026 ETC" --version-string 1.2.3.0
163
+
164
+ # 打包项目压缩包(自动解压、找 main.py、带上资源文件)
165
+ pytoexe --cli 项目.zip --onefile --bundle --output-dir dist
166
+
167
+ # 不用内置环境,改用当前 Python(不推荐)
168
+ pytoexe --cli main.py --no-venv
169
+ ```
170
+
171
+ ## 出错时会发生什么
172
+
173
+ 打包失败后会自动做这些事:
174
+
175
+ 1. 从日志里找出异常类型、模块名、出错文件和行号;
176
+ 2. 翻译成中文原因(例如 “缺少 Python 模块:pandas”“位数不匹配”“没有写入权限”);
177
+ 3. 给出针对性的处理建议;
178
+ 4. 弹出“打包出错”窗口,展示原因、出错位置、建议,并提供“复制完整诊断”“打开日志文件”;
179
+ 5. 完整日志同时写入 `~/.pytoexe/logs/`。
180
+
181
+ ## 兼容性
182
+
183
+ - Python 3.8 ~ 3.14
184
+ - Windows / Linux / macOS
185
+ - PyInstaller 5.8 及以上(Python 3.8 环境会自动选择 5.x/6.x 兼容版本)
186
+ - 界面基于 Eel,需要 Chrome / Edge 或系统默认浏览器
187
+
188
+ ## 开发
189
+
190
+ ```bash
191
+ git clone https://github.com/ETQWFD/pytoexe.git
192
+ cd pytoexe
193
+ pip install -e ".[dev]"
194
+ pytest
195
+ python -m pytoexe
196
+ ```
197
+
198
+ 构建发行包:
199
+
200
+ ```bash
201
+ python -m build
202
+ twine check dist/*
203
+
204
+ # 发布到 PyPI(需要先在 pypi.org 创建 API Token)
205
+ PYPI_API_TOKEN=pypi-xxxx bash scripts/publish.sh
206
+ ```
207
+
208
+ > 如果 PyPI 上出现 CalledSetup 错误,说明该版本号已存在,修改 `pyproject.toml` 里的 version 后重新构建即可。
209
+
210
+ ## 目录结构
211
+
212
+ ```
213
+ pytoexe/
214
+ ├── pytoexe/
215
+ │ ├── __main__.py # 入口(GUI / CLI / doctor)
216
+ │ ├── packaging.py # 打包主流程(依赖闸门、证书、分发)
217
+ │ ├── project.py # .py / .zip 项目准备(main.py 定位、资源收集)
218
+ │ ├── certificate.py # .pfx/.p12 证书校验
219
+ │ ├── env_manager.py # 虚拟环境创建、依赖同步与清理
220
+ │ ├── depscan.py # import 扫描与模块→发行包映射
221
+ │ ├── exeinfo.py # 版本信息资源生成、证书签名
222
+ │ ├── diagnostics.py # 英文报错 → 中文诊断
223
+ │ ├── ui.py # Eel 后端接口
224
+ │ └── web/ # 全中文界面(HTML/CSS/JS)
225
+ ├── examples/ # 可直接打包的示例
226
+ ├── tests/ # 单元测试
227
+ └── .github/workflows/ # 测试与发布流水线
228
+ ```
229
+
230
+ ## 致谢与许可
231
+
232
+ - 本项目基于 **auto-py-to-exe**(Copyright © 2018 Brent Vollebregt,MIT License)二次开发,
233
+ 原始版权声明保留在 `LICENSE` 中。
234
+ - 打包引擎为 [PyInstaller](https://pyinstaller.org/)。
235
+ - 本项目同样使用 MIT License,作者 **by ETC**。
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pytoexe-gui"
7
+ version = "1.1.0"
8
+ description = "把 Python 脚本或项目压缩包打包成可执行程序的中文图形工具:全自动虚拟环境与依赖安装、依赖闸门、程序属性/版权/证书校验与签名、打包后分发,by ETC"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "ETC", email = "et2416444244@outlook.com" }]
13
+ keywords = ["pyinstaller", "exe", "zip", "gui", "packaging", "python", "中文"]
14
+ classifiers = [
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.8",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Operating System :: Microsoft :: Windows",
24
+ "Operating System :: POSIX :: Linux",
25
+ "Operating System :: MacOS",
26
+ "Environment :: X11 Applications",
27
+ "Topic :: Software Development :: Build Tools",
28
+ "Natural Language :: Chinese (Simplified)",
29
+ ]
30
+ dependencies = [
31
+ "Eel>=0.11.0,!=0.18.0",
32
+ "pyinstaller>=5.8.0",
33
+ "requests>=2.25.0",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/ETQWFD/pytoexe"
38
+ Repository = "https://github.com/ETQWFD/pytoexe"
39
+ "Bug Tracker" = "https://github.com/ETQWFD/pytoexe/issues"
40
+ Changelog = "https://github.com/ETQWFD/pytoexe/blob/main/CHANGELOG.md"
41
+
42
+ [project.scripts]
43
+ pytoexe = "pytoexe.__main__:run"
44
+ pytoexe-gui = "pytoexe.__main__:run"
45
+
46
+ [project.optional-dependencies]
47
+ dev = ["pytest>=7", "build>=0.10", "twine>=4"]
48
+
49
+ [tool.setuptools]
50
+ packages = ["pytoexe"]
51
+ include-package-data = true
52
+ zip-safe = false
53
+
54
+ [tool.setuptools.package-data]
55
+ pytoexe = [
56
+ "web/index.html",
57
+ "web/favicon.ico",
58
+ "web/*.ttf",
59
+ "web/css/*.css",
60
+ "web/js/*.js",
61
+ "web/img/*.svg",
62
+ ]
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
66
+ addopts = "-q"