crogram-pythub 0.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 (31) hide show
  1. crogram_pythub-0.1.0/LICENSE +21 -0
  2. crogram_pythub-0.1.0/PKG-INFO +148 -0
  3. crogram_pythub-0.1.0/README.md +124 -0
  4. crogram_pythub-0.1.0/pyproject.toml +40 -0
  5. crogram_pythub-0.1.0/setup.cfg +4 -0
  6. crogram_pythub-0.1.0/src/crogram_pythub.egg-info/PKG-INFO +148 -0
  7. crogram_pythub-0.1.0/src/crogram_pythub.egg-info/SOURCES.txt +29 -0
  8. crogram_pythub-0.1.0/src/crogram_pythub.egg-info/dependency_links.txt +1 -0
  9. crogram_pythub-0.1.0/src/crogram_pythub.egg-info/entry_points.txt +3 -0
  10. crogram_pythub-0.1.0/src/crogram_pythub.egg-info/top_level.txt +1 -0
  11. crogram_pythub-0.1.0/src/pythub/__init__.py +22 -0
  12. crogram_pythub-0.1.0/src/pythub/__main__.py +6 -0
  13. crogram_pythub-0.1.0/src/pythub/analyzer.py +142 -0
  14. crogram_pythub-0.1.0/src/pythub/bootloader/bootex.c +1310 -0
  15. crogram_pythub-0.1.0/src/pythub/bootloader/miniz_LICENSE +22 -0
  16. crogram_pythub-0.1.0/src/pythub/bootloader/miniz_common.h +146 -0
  17. crogram_pythub-0.1.0/src/pythub/bootloader/miniz_export.h +5 -0
  18. crogram_pythub-0.1.0/src/pythub/bootloader/miniz_tinfl.c +765 -0
  19. crogram_pythub-0.1.0/src/pythub/bootloader/miniz_tinfl.h +148 -0
  20. crogram_pythub-0.1.0/src/pythub/builder.py +421 -0
  21. crogram_pythub-0.1.0/src/pythub/cli.py +348 -0
  22. crogram_pythub-0.1.0/src/pythub/config.py +77 -0
  23. crogram_pythub-0.1.0/src/pythub/deps.py +90 -0
  24. crogram_pythub-0.1.0/src/pythub/exe_archive.py +414 -0
  25. crogram_pythub-0.1.0/src/pythub/formats.py +227 -0
  26. crogram_pythub-0.1.0/src/pythub/gui.py +690 -0
  27. crogram_pythub-0.1.0/src/pythub/native_builder.py +71 -0
  28. crogram_pythub-0.1.0/src/pythub/pypa.py +213 -0
  29. crogram_pythub-0.1.0/src/pythub/runtime.py +336 -0
  30. crogram_pythub-0.1.0/src/pythub/signing.py +104 -0
  31. crogram_pythub-0.1.0/src/pythub/utils.py +330 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CROGRAM (https://crogram.org)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: crogram-pythub
3
+ Version: 0.1.0
4
+ Summary: 开源的 Python 应用打包工具:一条命令把 Python 应用打包成免装 Python、可直接运行的产物(跨平台、多 Python 版本、多架构),并支持发布到 PyPI
5
+ Author: CROGRAM
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://crogram.org
8
+ Project-URL: Repository, https://github.com/crogram/pythub
9
+ Project-URL: Issues, https://github.com/crogram/pythub/issues
10
+ Keywords: package,bundle,cross-platform,pyinstaller,zipapp,pypi
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Environment :: X11 Applications
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Build Tools
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # Pythub
26
+
27
+ **Pythub** 是一个开源的基于 Python 的 Python 应用打包工具:
28
+ **一条命令,把应用打包成免装 Python、可直接运行的产物**——在一个平台上即可交叉打包 Windows / macOS / Linux 多平台、多版本 Python、多架构的自包含产物,并支持打包/发布 PyPI 包。
29
+
30
+ > 版权归属开源组织 **CROGRAM** · https://crogram.org
31
+
32
+ ## 特性
33
+
34
+ - **跨平台交叉打包**:在 Mac 上打包 Windows `.exe`(自研引导器)/`.exe.zip`、Linux `tar.gz`/`.run`/AppImage;在 Windows 上打包 macOS `tar.gz` 等
35
+ - **多 Python 版本**:3.10 / 3.11 / 3.12(产物内嵌目标版本解释器,目标机器**免装 Python**)
36
+ - **运行时自动瘦身**:官方 stripped 运行时 + 剪除 test/idlelib/pip/调试符号等冗余,Windows `.exe.zip` 体积降低约 76%(55M→13M)
37
+ - **多架构**:x86_64 / aarch64(含 Apple Silicon、Windows ARM64)
38
+ - **平台专属格式**:`.app` / `.dmg` / `.pkg`(macOS)、AppImage / `tar.gz` / 单文件自解压 `.run` / 原生单文件 `.nexe`(Linux)、`.exe.zip` / 单文件 `.exe`(Windows,自研 C 引导器 + 自研压缩归档 + stdlib zip 化,实测 12.3MB)、单文件 `pyz`;macOS/Linux 的 `.nexe` 为原生单文件可执行(同一套自研 C 引导器与归档格式,仅本机平台生成)
39
+ - **智能组件选择**:自动分析 import,按目标平台下载对应平台的第三方组件(Mac 打包只带 Mac 组件,Windows 打包只带 Windows 组件)
40
+ - **双引擎**:默认 `zipapp` 引擎(自研、支持交叉);可选 `pyinstaller` 引擎生成本机真单文件二进制
41
+ - **命令行 + GUI**:`pythub`(argparse)与 `pythub-gui`(tkinter),组件全部为 Python 内置或自研实现
42
+ - **PyPI 生态**:`pythub pypa build` 打 sdist/wheel,`pythub pypa publish` 直接发布到 PyPI(stdlib 实现);Pythub 自身亦可发布到 PyPI(`pip install crogram-pythub`)
43
+
44
+ ## 安装
45
+
46
+ ```bash
47
+ # 生产模式安装,本地仓库
48
+ pip install .
49
+
50
+ # 克隆源码
51
+ git clone https://github.com/crogram/pythub.git
52
+ cd pythub
53
+
54
+ # 开发模式安装(修改代码立即生效)
55
+ pip install -e .
56
+
57
+ # 发布后:
58
+ pip install crogram-pythub
59
+ ```
60
+
61
+ ## 服务管理
62
+
63
+ ## 快速开始
64
+
65
+ ```bash
66
+ # 1. 创建示例工程
67
+ pythub init
68
+
69
+ # 2. 分析依赖
70
+ pythub analyze hello_app
71
+
72
+ # 3. 交叉打包:在任意平台打包所有平台产物(默认 Python 3.12)
73
+ pythub build hello_app -p all
74
+
75
+ # 指定平台/格式/Python 版本/架构
76
+ pythub build hello_app -p windows -f exe.zip --py 3.11
77
+ pythub build hello_app -p macos -f app --arch aarch64
78
+ pythub build hello_app -p linux -f appimage
79
+ pythub build hello_app -p linux -f run
80
+
81
+ # 本机生成真正的单文件二进制(需 pip install pyinstaller)
82
+ pythub build hello_app -p macos -f onefile --engine pyinstaller
83
+
84
+ # 4. 可视化界面
85
+ pythub gui
86
+
87
+ PYTHONPATH=src python3.11 -m pythub gui
88
+ ```
89
+
90
+ ## 打包为 PyPI 包并发布
91
+
92
+ ```bash
93
+ pythub pypa build hello_app -o dist # 生成 sdist + wheel
94
+ pythub pypa publish dist/*.whl --repo pypi --token pypi-xxxx
95
+ ```
96
+
97
+ GUI 的「发布 PyPI」页同样可选择 dist 中的文件直接上传。
98
+
99
+ ## 产物格式矩阵
100
+
101
+ | 目标平台 | 格式 | 默认 | 交叉支持 |
102
+ |---|---|---|---|
103
+ | Windows | `exe.zip` / `exe` / `dir` / `pyz` | exe.zip | ✅(`.exe` 单文件需构建机有 mingw-w64:`brew install mingw-w64`,自研 C 引导器交叉编译) |
104
+ | Linux | `tar.gz` / `nexe` / `run` / `appimage` / `dir` / `pyz` | tar.gz | ✅(`nexe` 原生 ELF 单文件仅本机平台生成;`.run` 单文件自解压可执行,零依赖可交叉;AppImage 需构建机有 appimagetool,缺失时降级 `.run`) |
105
+ | macOS | `app` / `dmg` / `pkg` / `tar.gz` / `nexe` / `dir` / `pyz` | app | `nexe` 原生 Mach-O 单文件(自研 C 引导器 + 归档)需在 macOS 上打包;其余可交叉 |
106
+
107
+ 说明:Python 生态中真正的"交叉编译二进制"受解释器限制。Pythub 的 zipapp 引擎采用
108
+ **自包含产物**方案(内嵌 python-build-standalone 独立解释器 + zipapp + 平台启动器),
109
+ 目标机器解压即可运行、无需安装 Python;需要真正单文件二进制时,在本机平台使用
110
+ `--engine pyinstaller`。
111
+
112
+ ## 工程配置 `pythub.toml`
113
+
114
+ ```toml
115
+ [app]
116
+ name = "hello-pythub"
117
+ entry = "main.py"
118
+ version = "0.1.0"
119
+ description = "示例应用"
120
+ author = "CROGRAM"
121
+ requirements = ["requests"] # 第三方依赖;也可用 requirements.txt
122
+ windowed = false # true: GUI 应用隐藏控制台黑框(exe 引导器 -mwindows;app/.app 同样生效)
123
+ ```
124
+
125
+ ## 项目结构
126
+
127
+ ```
128
+ src/pythub/
129
+ ├── cli.py # 命令行入口
130
+ ├── gui.py # tkinter 可视化界面
131
+ ├── config.py # pythub.toml / requirements 解析
132
+ ├── analyzer.py # AST 依赖分析(标准库/第三方/发行包映射)
133
+ ├── deps.py # 按目标平台下载 wheel(pip 交叉下载)
134
+ ├── runtime.py # 嵌入式 Python 运行时下载与缓存
135
+ ├── builder.py # 打包主流程(zipapp 引擎)
136
+ ├── formats.py # .app/.dmg/.pkg/AppImage/.exe.zip/.run/.exe 格式实现
137
+ ├── exe_archive.py # 自研 Windows 单文件 .exe 打包器(zlib 压缩归档 + stdlib zip 化 + 引导器交叉编译缓存)
138
+ ├── bootloader/
139
+ │ └── bootex.c # 自研单文件引导器源码(Windows PE / POSIX 双分支)
140
+ ├── native_builder.py # PyInstaller 引擎(本机真二进制)
141
+ └── pypa.py # sdist/wheel 构建 + PyPI 上传
142
+ examples/hello_app/ # 示例工程(测试与验证用)
143
+ docs/ # 原始需求与需求梳理清单
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT © CROGRAM
@@ -0,0 +1,124 @@
1
+ # Pythub
2
+
3
+ **Pythub** 是一个开源的基于 Python 的 Python 应用打包工具:
4
+ **一条命令,把应用打包成免装 Python、可直接运行的产物**——在一个平台上即可交叉打包 Windows / macOS / Linux 多平台、多版本 Python、多架构的自包含产物,并支持打包/发布 PyPI 包。
5
+
6
+ > 版权归属开源组织 **CROGRAM** · https://crogram.org
7
+
8
+ ## 特性
9
+
10
+ - **跨平台交叉打包**:在 Mac 上打包 Windows `.exe`(自研引导器)/`.exe.zip`、Linux `tar.gz`/`.run`/AppImage;在 Windows 上打包 macOS `tar.gz` 等
11
+ - **多 Python 版本**:3.10 / 3.11 / 3.12(产物内嵌目标版本解释器,目标机器**免装 Python**)
12
+ - **运行时自动瘦身**:官方 stripped 运行时 + 剪除 test/idlelib/pip/调试符号等冗余,Windows `.exe.zip` 体积降低约 76%(55M→13M)
13
+ - **多架构**:x86_64 / aarch64(含 Apple Silicon、Windows ARM64)
14
+ - **平台专属格式**:`.app` / `.dmg` / `.pkg`(macOS)、AppImage / `tar.gz` / 单文件自解压 `.run` / 原生单文件 `.nexe`(Linux)、`.exe.zip` / 单文件 `.exe`(Windows,自研 C 引导器 + 自研压缩归档 + stdlib zip 化,实测 12.3MB)、单文件 `pyz`;macOS/Linux 的 `.nexe` 为原生单文件可执行(同一套自研 C 引导器与归档格式,仅本机平台生成)
15
+ - **智能组件选择**:自动分析 import,按目标平台下载对应平台的第三方组件(Mac 打包只带 Mac 组件,Windows 打包只带 Windows 组件)
16
+ - **双引擎**:默认 `zipapp` 引擎(自研、支持交叉);可选 `pyinstaller` 引擎生成本机真单文件二进制
17
+ - **命令行 + GUI**:`pythub`(argparse)与 `pythub-gui`(tkinter),组件全部为 Python 内置或自研实现
18
+ - **PyPI 生态**:`pythub pypa build` 打 sdist/wheel,`pythub pypa publish` 直接发布到 PyPI(stdlib 实现);Pythub 自身亦可发布到 PyPI(`pip install crogram-pythub`)
19
+
20
+ ## 安装
21
+
22
+ ```bash
23
+ # 生产模式安装,本地仓库
24
+ pip install .
25
+
26
+ # 克隆源码
27
+ git clone https://github.com/crogram/pythub.git
28
+ cd pythub
29
+
30
+ # 开发模式安装(修改代码立即生效)
31
+ pip install -e .
32
+
33
+ # 发布后:
34
+ pip install crogram-pythub
35
+ ```
36
+
37
+ ## 服务管理
38
+
39
+ ## 快速开始
40
+
41
+ ```bash
42
+ # 1. 创建示例工程
43
+ pythub init
44
+
45
+ # 2. 分析依赖
46
+ pythub analyze hello_app
47
+
48
+ # 3. 交叉打包:在任意平台打包所有平台产物(默认 Python 3.12)
49
+ pythub build hello_app -p all
50
+
51
+ # 指定平台/格式/Python 版本/架构
52
+ pythub build hello_app -p windows -f exe.zip --py 3.11
53
+ pythub build hello_app -p macos -f app --arch aarch64
54
+ pythub build hello_app -p linux -f appimage
55
+ pythub build hello_app -p linux -f run
56
+
57
+ # 本机生成真正的单文件二进制(需 pip install pyinstaller)
58
+ pythub build hello_app -p macos -f onefile --engine pyinstaller
59
+
60
+ # 4. 可视化界面
61
+ pythub gui
62
+
63
+ PYTHONPATH=src python3.11 -m pythub gui
64
+ ```
65
+
66
+ ## 打包为 PyPI 包并发布
67
+
68
+ ```bash
69
+ pythub pypa build hello_app -o dist # 生成 sdist + wheel
70
+ pythub pypa publish dist/*.whl --repo pypi --token pypi-xxxx
71
+ ```
72
+
73
+ GUI 的「发布 PyPI」页同样可选择 dist 中的文件直接上传。
74
+
75
+ ## 产物格式矩阵
76
+
77
+ | 目标平台 | 格式 | 默认 | 交叉支持 |
78
+ |---|---|---|---|
79
+ | Windows | `exe.zip` / `exe` / `dir` / `pyz` | exe.zip | ✅(`.exe` 单文件需构建机有 mingw-w64:`brew install mingw-w64`,自研 C 引导器交叉编译) |
80
+ | Linux | `tar.gz` / `nexe` / `run` / `appimage` / `dir` / `pyz` | tar.gz | ✅(`nexe` 原生 ELF 单文件仅本机平台生成;`.run` 单文件自解压可执行,零依赖可交叉;AppImage 需构建机有 appimagetool,缺失时降级 `.run`) |
81
+ | macOS | `app` / `dmg` / `pkg` / `tar.gz` / `nexe` / `dir` / `pyz` | app | `nexe` 原生 Mach-O 单文件(自研 C 引导器 + 归档)需在 macOS 上打包;其余可交叉 |
82
+
83
+ 说明:Python 生态中真正的"交叉编译二进制"受解释器限制。Pythub 的 zipapp 引擎采用
84
+ **自包含产物**方案(内嵌 python-build-standalone 独立解释器 + zipapp + 平台启动器),
85
+ 目标机器解压即可运行、无需安装 Python;需要真正单文件二进制时,在本机平台使用
86
+ `--engine pyinstaller`。
87
+
88
+ ## 工程配置 `pythub.toml`
89
+
90
+ ```toml
91
+ [app]
92
+ name = "hello-pythub"
93
+ entry = "main.py"
94
+ version = "0.1.0"
95
+ description = "示例应用"
96
+ author = "CROGRAM"
97
+ requirements = ["requests"] # 第三方依赖;也可用 requirements.txt
98
+ windowed = false # true: GUI 应用隐藏控制台黑框(exe 引导器 -mwindows;app/.app 同样生效)
99
+ ```
100
+
101
+ ## 项目结构
102
+
103
+ ```
104
+ src/pythub/
105
+ ├── cli.py # 命令行入口
106
+ ├── gui.py # tkinter 可视化界面
107
+ ├── config.py # pythub.toml / requirements 解析
108
+ ├── analyzer.py # AST 依赖分析(标准库/第三方/发行包映射)
109
+ ├── deps.py # 按目标平台下载 wheel(pip 交叉下载)
110
+ ├── runtime.py # 嵌入式 Python 运行时下载与缓存
111
+ ├── builder.py # 打包主流程(zipapp 引擎)
112
+ ├── formats.py # .app/.dmg/.pkg/AppImage/.exe.zip/.run/.exe 格式实现
113
+ ├── exe_archive.py # 自研 Windows 单文件 .exe 打包器(zlib 压缩归档 + stdlib zip 化 + 引导器交叉编译缓存)
114
+ ├── bootloader/
115
+ │ └── bootex.c # 自研单文件引导器源码(Windows PE / POSIX 双分支)
116
+ ├── native_builder.py # PyInstaller 引擎(本机真二进制)
117
+ └── pypa.py # sdist/wheel 构建 + PyPI 上传
118
+ examples/hello_app/ # 示例工程(测试与验证用)
119
+ docs/ # 原始需求与需求梳理清单
120
+ ```
121
+
122
+ ## License
123
+
124
+ MIT © CROGRAM
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "crogram-pythub"
7
+ version = "0.1.0"
8
+ description = "开源的 Python 应用打包工具:一条命令把 Python 应用打包成免装 Python、可直接运行的产物(跨平台、多 Python 版本、多架构),并支持发布到 PyPI"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "CROGRAM" }]
14
+ keywords = ["package", "bundle", "cross-platform", "pyinstaller", "zipapp", "pypi"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: Console",
18
+ "Environment :: X11 Applications",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Build Tools",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://crogram.org"
29
+ Repository = "https://github.com/crogram/pythub"
30
+ Issues = "https://github.com/crogram/pythub/issues"
31
+
32
+ [project.scripts]
33
+ pythub = "pythub.cli:main"
34
+ pythub-gui = "pythub.gui:main"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.setuptools.package-data]
40
+ pythub = ["bootloader/*.c", "bootloader/*.h", "bootloader/miniz_LICENSE"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: crogram-pythub
3
+ Version: 0.1.0
4
+ Summary: 开源的 Python 应用打包工具:一条命令把 Python 应用打包成免装 Python、可直接运行的产物(跨平台、多 Python 版本、多架构),并支持发布到 PyPI
5
+ Author: CROGRAM
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://crogram.org
8
+ Project-URL: Repository, https://github.com/crogram/pythub
9
+ Project-URL: Issues, https://github.com/crogram/pythub/issues
10
+ Keywords: package,bundle,cross-platform,pyinstaller,zipapp,pypi
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Environment :: X11 Applications
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Build Tools
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # Pythub
26
+
27
+ **Pythub** 是一个开源的基于 Python 的 Python 应用打包工具:
28
+ **一条命令,把应用打包成免装 Python、可直接运行的产物**——在一个平台上即可交叉打包 Windows / macOS / Linux 多平台、多版本 Python、多架构的自包含产物,并支持打包/发布 PyPI 包。
29
+
30
+ > 版权归属开源组织 **CROGRAM** · https://crogram.org
31
+
32
+ ## 特性
33
+
34
+ - **跨平台交叉打包**:在 Mac 上打包 Windows `.exe`(自研引导器)/`.exe.zip`、Linux `tar.gz`/`.run`/AppImage;在 Windows 上打包 macOS `tar.gz` 等
35
+ - **多 Python 版本**:3.10 / 3.11 / 3.12(产物内嵌目标版本解释器,目标机器**免装 Python**)
36
+ - **运行时自动瘦身**:官方 stripped 运行时 + 剪除 test/idlelib/pip/调试符号等冗余,Windows `.exe.zip` 体积降低约 76%(55M→13M)
37
+ - **多架构**:x86_64 / aarch64(含 Apple Silicon、Windows ARM64)
38
+ - **平台专属格式**:`.app` / `.dmg` / `.pkg`(macOS)、AppImage / `tar.gz` / 单文件自解压 `.run` / 原生单文件 `.nexe`(Linux)、`.exe.zip` / 单文件 `.exe`(Windows,自研 C 引导器 + 自研压缩归档 + stdlib zip 化,实测 12.3MB)、单文件 `pyz`;macOS/Linux 的 `.nexe` 为原生单文件可执行(同一套自研 C 引导器与归档格式,仅本机平台生成)
39
+ - **智能组件选择**:自动分析 import,按目标平台下载对应平台的第三方组件(Mac 打包只带 Mac 组件,Windows 打包只带 Windows 组件)
40
+ - **双引擎**:默认 `zipapp` 引擎(自研、支持交叉);可选 `pyinstaller` 引擎生成本机真单文件二进制
41
+ - **命令行 + GUI**:`pythub`(argparse)与 `pythub-gui`(tkinter),组件全部为 Python 内置或自研实现
42
+ - **PyPI 生态**:`pythub pypa build` 打 sdist/wheel,`pythub pypa publish` 直接发布到 PyPI(stdlib 实现);Pythub 自身亦可发布到 PyPI(`pip install crogram-pythub`)
43
+
44
+ ## 安装
45
+
46
+ ```bash
47
+ # 生产模式安装,本地仓库
48
+ pip install .
49
+
50
+ # 克隆源码
51
+ git clone https://github.com/crogram/pythub.git
52
+ cd pythub
53
+
54
+ # 开发模式安装(修改代码立即生效)
55
+ pip install -e .
56
+
57
+ # 发布后:
58
+ pip install crogram-pythub
59
+ ```
60
+
61
+ ## 服务管理
62
+
63
+ ## 快速开始
64
+
65
+ ```bash
66
+ # 1. 创建示例工程
67
+ pythub init
68
+
69
+ # 2. 分析依赖
70
+ pythub analyze hello_app
71
+
72
+ # 3. 交叉打包:在任意平台打包所有平台产物(默认 Python 3.12)
73
+ pythub build hello_app -p all
74
+
75
+ # 指定平台/格式/Python 版本/架构
76
+ pythub build hello_app -p windows -f exe.zip --py 3.11
77
+ pythub build hello_app -p macos -f app --arch aarch64
78
+ pythub build hello_app -p linux -f appimage
79
+ pythub build hello_app -p linux -f run
80
+
81
+ # 本机生成真正的单文件二进制(需 pip install pyinstaller)
82
+ pythub build hello_app -p macos -f onefile --engine pyinstaller
83
+
84
+ # 4. 可视化界面
85
+ pythub gui
86
+
87
+ PYTHONPATH=src python3.11 -m pythub gui
88
+ ```
89
+
90
+ ## 打包为 PyPI 包并发布
91
+
92
+ ```bash
93
+ pythub pypa build hello_app -o dist # 生成 sdist + wheel
94
+ pythub pypa publish dist/*.whl --repo pypi --token pypi-xxxx
95
+ ```
96
+
97
+ GUI 的「发布 PyPI」页同样可选择 dist 中的文件直接上传。
98
+
99
+ ## 产物格式矩阵
100
+
101
+ | 目标平台 | 格式 | 默认 | 交叉支持 |
102
+ |---|---|---|---|
103
+ | Windows | `exe.zip` / `exe` / `dir` / `pyz` | exe.zip | ✅(`.exe` 单文件需构建机有 mingw-w64:`brew install mingw-w64`,自研 C 引导器交叉编译) |
104
+ | Linux | `tar.gz` / `nexe` / `run` / `appimage` / `dir` / `pyz` | tar.gz | ✅(`nexe` 原生 ELF 单文件仅本机平台生成;`.run` 单文件自解压可执行,零依赖可交叉;AppImage 需构建机有 appimagetool,缺失时降级 `.run`) |
105
+ | macOS | `app` / `dmg` / `pkg` / `tar.gz` / `nexe` / `dir` / `pyz` | app | `nexe` 原生 Mach-O 单文件(自研 C 引导器 + 归档)需在 macOS 上打包;其余可交叉 |
106
+
107
+ 说明:Python 生态中真正的"交叉编译二进制"受解释器限制。Pythub 的 zipapp 引擎采用
108
+ **自包含产物**方案(内嵌 python-build-standalone 独立解释器 + zipapp + 平台启动器),
109
+ 目标机器解压即可运行、无需安装 Python;需要真正单文件二进制时,在本机平台使用
110
+ `--engine pyinstaller`。
111
+
112
+ ## 工程配置 `pythub.toml`
113
+
114
+ ```toml
115
+ [app]
116
+ name = "hello-pythub"
117
+ entry = "main.py"
118
+ version = "0.1.0"
119
+ description = "示例应用"
120
+ author = "CROGRAM"
121
+ requirements = ["requests"] # 第三方依赖;也可用 requirements.txt
122
+ windowed = false # true: GUI 应用隐藏控制台黑框(exe 引导器 -mwindows;app/.app 同样生效)
123
+ ```
124
+
125
+ ## 项目结构
126
+
127
+ ```
128
+ src/pythub/
129
+ ├── cli.py # 命令行入口
130
+ ├── gui.py # tkinter 可视化界面
131
+ ├── config.py # pythub.toml / requirements 解析
132
+ ├── analyzer.py # AST 依赖分析(标准库/第三方/发行包映射)
133
+ ├── deps.py # 按目标平台下载 wheel(pip 交叉下载)
134
+ ├── runtime.py # 嵌入式 Python 运行时下载与缓存
135
+ ├── builder.py # 打包主流程(zipapp 引擎)
136
+ ├── formats.py # .app/.dmg/.pkg/AppImage/.exe.zip/.run/.exe 格式实现
137
+ ├── exe_archive.py # 自研 Windows 单文件 .exe 打包器(zlib 压缩归档 + stdlib zip 化 + 引导器交叉编译缓存)
138
+ ├── bootloader/
139
+ │ └── bootex.c # 自研单文件引导器源码(Windows PE / POSIX 双分支)
140
+ ├── native_builder.py # PyInstaller 引擎(本机真二进制)
141
+ └── pypa.py # sdist/wheel 构建 + PyPI 上传
142
+ examples/hello_app/ # 示例工程(测试与验证用)
143
+ docs/ # 原始需求与需求梳理清单
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT © CROGRAM
@@ -0,0 +1,29 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/crogram_pythub.egg-info/PKG-INFO
5
+ src/crogram_pythub.egg-info/SOURCES.txt
6
+ src/crogram_pythub.egg-info/dependency_links.txt
7
+ src/crogram_pythub.egg-info/entry_points.txt
8
+ src/crogram_pythub.egg-info/top_level.txt
9
+ src/pythub/__init__.py
10
+ src/pythub/__main__.py
11
+ src/pythub/analyzer.py
12
+ src/pythub/builder.py
13
+ src/pythub/cli.py
14
+ src/pythub/config.py
15
+ src/pythub/deps.py
16
+ src/pythub/exe_archive.py
17
+ src/pythub/formats.py
18
+ src/pythub/gui.py
19
+ src/pythub/native_builder.py
20
+ src/pythub/pypa.py
21
+ src/pythub/runtime.py
22
+ src/pythub/signing.py
23
+ src/pythub/utils.py
24
+ src/pythub/bootloader/bootex.c
25
+ src/pythub/bootloader/miniz_LICENSE
26
+ src/pythub/bootloader/miniz_common.h
27
+ src/pythub/bootloader/miniz_export.h
28
+ src/pythub/bootloader/miniz_tinfl.c
29
+ src/pythub/bootloader/miniz_tinfl.h
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ pythub = pythub.cli:main
3
+ pythub-gui = pythub.gui:main
@@ -0,0 +1,22 @@
1
+ """Pythub —— 开源的基于 Python 的 Python 应用打包工具。
2
+
3
+ 版权归属开源组织 CROGRAM (https://crogram.org)
4
+ """
5
+
6
+ __version__ = "0.1.0"
7
+ __author__ = "CROGRAM"
8
+ __url__ = "https://crogram.org"
9
+
10
+ SUPPORTED_PLATFORMS = ("macos", "linux", "windows")
11
+ SUPPORTED_ARCHS = ("x86_64", "aarch64")
12
+ SUPPORTED_PYTHON = ("3.10", "3.11", "3.12")
13
+
14
+ # 各平台可用输出格式(按优先级排序)
15
+ # nexe: 自研原生单文件可执行(macOS Mach-O / Linux ELF,仅本机平台+架构可生成)
16
+ PLATFORM_FORMATS = {
17
+ "macos": ["app", "dmg", "pkg", "tar.gz", "nexe", "dir", "pyz"],
18
+ "linux": ["tar.gz", "nexe", "run", "appimage", "dir", "pyz"],
19
+ "windows": ["exe.zip", "exe", "dir", "pyz"],
20
+ }
21
+
22
+ DEFAULT_FORMAT = {"macos": "app", "linux": "tar.gz", "windows": "exe.zip"}
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from pythub.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())