|
1 | | -# PyMeshGen 打包工具使用说明 |
| 1 | +# PyMeshGen Packaging and Publishing Guide |
2 | 2 |
|
3 | | -## 🚀 快速开始 |
| 3 | +## Preferred distribution path |
4 | 4 |
|
5 | | -### 标准 Python 分发构建 |
| 5 | +PyMeshGen now treats **Python packaging as the primary release path**: |
| 6 | + |
| 7 | +1. build `sdist` + `wheel` |
| 8 | +2. validate the distributions |
| 9 | +3. publish to **PyPI** |
| 10 | +4. keep Windows executable packaging as an optional secondary path |
| 11 | + |
| 12 | +For most users, the intended installation target is: |
| 13 | + |
| 14 | +```bash |
| 15 | +pip install pymeshgen |
| 16 | +``` |
| 17 | + |
| 18 | +## Standard Python package build |
6 | 19 |
|
7 | 20 | ```bash |
8 | | -python -m pip install build |
| 21 | +python -m pip install --upgrade build twine |
9 | 22 | python -m build |
| 23 | +python -m twine check dist/* |
10 | 24 | ``` |
11 | 25 |
|
12 | | -构建产物会输出到 `dist/`,这是当前推荐的源码包 / wheel 构建方式。`setup.py` 仅保留为兼容层,不再作为主要入口。 |
| 26 | +Artifacts are written to `dist/`: |
13 | 27 |
|
14 | | -### 一键打包(推荐) |
| 28 | +| File | Description | |
| 29 | +|------|-------------| |
| 30 | +| `dist/pymeshgen-<version>.tar.gz` | Source distribution | |
| 31 | +| `dist/pymeshgen-<version>-py3-none-any.whl` | Wheel | |
15 | 32 |
|
16 | | -**Windows 用户**:双击运行 `build.bat` |
| 33 | +Versioning is sourced from the repository `VERSION` file. Update `VERSION` before creating a release tag. |
17 | 34 |
|
18 | | -**命令行方式**: |
19 | | -```bash |
20 | | -# 基本打包(仅生成可执行文件) |
21 | | -python build_app.py |
| 35 | +## PyPI publishing |
22 | 36 |
|
23 | | -# 清理后打包并创建 ZIP 便携版 |
24 | | -python build_app.py --clean --zip |
| 37 | +### Recommended: GitHub Actions + Trusted Publisher |
25 | 38 |
|
26 | | -# 创建所有格式(可执行文件 + 安装包 + ZIP) |
27 | | -python build_app.py --all |
| 39 | +This repository now includes: |
| 40 | + |
| 41 | +- `.github/workflows/python-package.yml` — builds and validates the Python package on push / pull request |
| 42 | +- `.github/workflows/publish-pypi.yml` — publishes to TestPyPI or PyPI through GitHub Actions |
| 43 | + |
| 44 | +### One-time PyPI setup |
| 45 | + |
| 46 | +In **PyPI** and **TestPyPI**, configure a Trusted Publisher for this repository: |
| 47 | + |
| 48 | +- **Owner**: `cfd-dev` |
| 49 | +- **Repository**: `PyMeshGen` |
| 50 | +- **Workflow**: `publish-pypi.yml` |
| 51 | +- **Environment**: |
| 52 | + - `testpypi` for TestPyPI |
| 53 | + - `pypi` for PyPI |
| 54 | + |
| 55 | +After that: |
| 56 | + |
| 57 | +- **Manual TestPyPI publish**: run the `Publish Python package` workflow with `repository = testpypi` |
| 58 | +- **Official PyPI publish**: create a GitHub Release from a version tag such as `v1.0.1` |
| 59 | + |
| 60 | +### Release flow |
| 61 | + |
| 62 | +1. Update `VERSION` |
| 63 | +2. Commit changes |
| 64 | +3. Tag the release |
| 65 | + ```bash |
| 66 | + git tag v1.0.1 |
| 67 | + git push origin master --tags |
| 68 | + ``` |
| 69 | +4. Draft / publish the GitHub Release |
| 70 | +5. GitHub Actions publishes the wheel and sdist to PyPI |
| 71 | + |
| 72 | +## Manual fallback publishing |
| 73 | + |
| 74 | +If you need to publish from a local machine instead of GitHub Actions: |
| 75 | + |
| 76 | +```bash |
| 77 | +python -m pip install --upgrade build twine |
| 78 | +python -m build |
| 79 | +python -m twine check dist/* |
| 80 | +python -m twine upload dist/* |
28 | 81 | ``` |
29 | 82 |
|
30 | | -## 📦 输出文件 |
| 83 | +For TestPyPI: |
31 | 84 |
|
32 | | -| 文件 | 位置 | 说明 | |
33 | | -|------|------|------| |
34 | | -| Python 源码包 / Wheel | `dist/` | 标准 Python 分发产物(`python -m build`) | |
35 | | -| 可执行文件 | `dist/PyMeshGen.exe` | 独立运行的程序 | |
36 | | -| ZIP 便携版 | `releases/PyMeshGen-v*.zip` | 压缩的便携版本 | |
37 | | -| Windows 安装包 | `installer/PyMeshGen-Setup-*.exe` | 标准安装程序(需 Inno Setup) | |
| 85 | +```bash |
| 86 | +python -m twine upload --repository testpypi dist/* |
| 87 | +``` |
38 | 88 |
|
39 | | -## 🔧 命令行参数 |
| 89 | +If you use a local `.pypirc`, keep it out of the repository. `.gitignore` already excludes it. |
40 | 90 |
|
41 | | -| 参数 | 说明 | |
42 | | -|------|------| |
43 | | -| `--clean` | 清理之前的构建文件 | |
44 | | -| `--debug` | 启用调试模式(显示控制台窗口) | |
45 | | -| `--installer` | 创建 Inno Setup 安装包 | |
46 | | -| `--zip` | 创建 ZIP 便携版 | |
47 | | -| `--all` | 创建所有输出格式 | |
48 | | -| `--skip-clean` | 跳过清理步骤 | |
| 91 | +## Installing the published package |
49 | 92 |
|
50 | | -## 📋 前置要求 |
| 93 | +### CLI |
51 | 94 |
|
52 | | -### 必需 |
53 | | -- Python 3.8+ |
54 | | -- pip 包管理器 |
55 | | -- `build`(用于标准 Python 包构建) |
| 95 | +```bash |
| 96 | +pip install pymeshgen |
| 97 | +pymeshgen --case ".\config\30p30n.json" |
| 98 | +``` |
56 | 99 |
|
57 | | -### 可选 |
58 | | -- **Inno Setup**:用于创建 Windows 安装包(如不需要安装包可忽略) |
| 100 | +### GUI |
59 | 101 |
|
60 | | -## 🛠️ 配置文件 |
| 102 | +```bash |
| 103 | +pip install pymeshgen |
| 104 | +pymeshgen-gui |
| 105 | +``` |
61 | 106 |
|
62 | | -### PyInstaller 配置 |
63 | | -编辑 `PyMeshGen.spec` 文件自定义: |
64 | | -- 包含的模块和数据文件 |
65 | | -- 图标 |
66 | | -- 版本信息 |
| 107 | +GUI usage still depends on GUI/runtime dependencies such as `PyQt5`, `vtk`, and `pythonocc-core`. |
67 | 108 |
|
68 | | -### Python 包构建配置 |
69 | | -标准 Python 包构建配置位于: |
70 | | -- `pyproject.toml`:PEP 517/518/621 元数据与构建入口 |
71 | | -- `setup.py`:仅保留非包资源收集的兼容层 |
72 | | -- `MANIFEST.in`:源码分发时需要包含的附加资源 |
| 109 | +## Optional Windows application packaging |
73 | 110 |
|
74 | | -### Inno Setup 配置 |
75 | | -编辑 `PyMeshGen.iss` 文件自定义: |
76 | | -- 安装程序界面 |
77 | | -- 安装目录 |
78 | | -- 快捷方式 |
| 111 | +Windows executable packaging is still available, but it is no longer the primary distribution mechanism. |
79 | 112 |
|
80 | | -## ⚠️ 注意事项 |
| 113 | +```bash |
| 114 | +python build_app.py |
| 115 | +python build_app.py --all |
| 116 | +``` |
81 | 117 |
|
82 | | -1. **打包时间**:首次打包约需 15-20 分钟(依赖大量科学计算库) |
83 | | -2. **文件大小**:可执行文件约 2-3GB(包含所有依赖) |
84 | | -3. **Inno Setup**:如未安装,脚本会自动跳过安装包创建 |
| 118 | +Typical outputs: |
85 | 119 |
|
86 | | -## 📖 详细文档 |
| 120 | +| File | Location | |
| 121 | +|------|----------| |
| 122 | +| Executable | `dist/PyMeshGen.exe` | |
| 123 | +| Portable ZIP | `releases/PyMeshGen-v*.zip` | |
| 124 | +| Windows installer | `installer/PyMeshGen-Setup-*.exe` | |
87 | 125 |
|
88 | | -- PyInstaller 文档:https://pyinstaller.org/ |
89 | | -- build 文档:https://build.pypa.io/ |
90 | | -- Inno Setup 文档:https://jrsoftware.org/ishelp/ |
| 126 | +This path depends on a fully prepared local Python environment plus PyInstaller, and is best treated as an optional desktop-delivery workflow rather than the main release channel. |
0 commit comments