Skip to content

Commit 35e24cb

Browse files
authored
Merge pull request #20 from muziing/dev
Version `0.3.1`
2 parents 5f3bc8b + 09f6533 commit 35e24cb

29 files changed

Lines changed: 1502 additions & 303 deletions

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Py2exe-GUI Logo](docs/source/images/py2exe-gui_logo_big.png)
1+
![Py2exe-GUI Logo](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png)
22

33
<h2 align="center">Easy-to-use Python GUI packaging tool</h2>
44

@@ -24,9 +24,9 @@ English | <a href="README_zh.md">简体中文</a>
2424
Py2exe-GUI is an assist tool based on [PySide6](https://doc.qt.io/qtforpython/index.html), designed to provide a
2525
complete yet easy-to-use GUI for [PyInstaller](https://pyinstaller.org/).
2626

27-
![Screenshot](docs/source/images/Py2exe-GUI_v0.3.0_mainwindow_screenshot.png)
27+
![Screenshot](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/Py2exe-GUI_v0.3.1_mainwindow_screenshot_en.png)
2828

29-
![Screenshot](docs/source/images/Py2exe-GUI_v0.2.0_screenshot.png)
29+
![Screenshot](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/Py2exe-GUI_v0.2.0_screenshot.png)
3030

3131
It has the following features:
3232

@@ -36,11 +36,6 @@ It has the following features:
3636
in each interpreter environment to be packaged.
3737
- Cross-platform, supports Windows, Linux and macOS.
3838

39-
> Note: As you can see, I am not an English speaker. Py2exe-GUI is currently only available in Simplified Chinese.
40-
> However, I've reserved some interfaces in the code for internationalization, and the translation is slowly progressing.
41-
> If you are interested in this project, you can star it. In a few months it will provide full English support and
42-
> interfaces for translators to provide translations in more languages.
43-
4439
## How to install
4540

4641
> Note: Py2exe-GUI is still in the early stages of development, and the distributions provided are *beta versions*.
@@ -112,7 +107,7 @@ the [checks](dev_scripts/check_funcs.py).
112107

113108
## License
114109

115-
![GPLv3](docs/source/images/gplv3-127x51.png)
110+
![GPLv3](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/gplv3-127x51.png)
116111

117112
Py2exe-GUI is licensed under the GPLv3 open source license, see the [LICENSE](LICENSE) file for details.
118113

README_zh.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Py2exe-GUI Logo](docs/source/images/py2exe-gui_logo_big.png)
1+
![Py2exe-GUI Logo](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png)
22

33
<h2 align="center">强大易用的 Python 图形界面打包工具</h2>
44

@@ -23,9 +23,9 @@
2323
Py2exe-GUI 是一个基于 [PySide6](https://doc.qt.io/qtforpython/index.html)
2424
开发的辅助工具,旨在为 [PyInstaller](https://pyinstaller.org/) 提供完整易用的图形化界面,方便用户进行 Python 项目的打包。
2525

26-
![界面截图](docs/source/images/Py2exe-GUI_v0.3.0_mainwindow_screenshot.png)
26+
![界面截图](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/Py2exe-GUI_v0.3.0_mainwindow_screenshot.png)
2727

28-
![界面截图](docs/source/images/Py2exe-GUI_v0.2.0_screenshot.png)
28+
![界面截图](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/Py2exe-GUI_v0.2.0_screenshot.png)
2929

3030
有如下特性:
3131

@@ -101,7 +101,7 @@ request。请尽可能遵守原有的代码风格,并确保新增代码能通
101101

102102
## 开源许可
103103

104-
![GPLv3](docs/source/images/gplv3-127x51.png)
104+
![GPLv3](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/gplv3-127x51.png)
105105

106106
Py2exe-GUI 采用 GPLv3 开源许可证,详情请参见 [LICENSE](LICENSE) 文件。
107107

dev_scripts/build.py

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33

44
import subprocess
5-
from pathlib import Path
65

76
from dev_scripts.check_funcs import (
87
check_license_statement,
@@ -11,63 +10,7 @@
1110
check_version_num,
1211
)
1312
from dev_scripts.clear_cache import clear_pycache, clear_pyinstaller_dist
14-
from dev_scripts.path_constants import (
15-
PROJECT_ROOT,
16-
README_FILE_LIST,
17-
RESOURCES_PATH,
18-
SRC_PATH,
19-
)
20-
21-
22-
def process_md_images(md_file_list: list[Path]) -> None:
23-
"""处理 Markdown 文档中的图片链接
24-
25-
在构建前替换为 GitHub 图床链接,在构建后替换回本地目录中的路径
26-
27-
:param md_file_list: Markdown 文件列表
28-
"""
29-
30-
md_uri = "docs/source/images/"
31-
github_uri = (
32-
"https://github.com/muziing/Py2exe-GUI/raw/main" + "/docs/source/images/"
33-
)
34-
35-
for md_file in md_file_list:
36-
with open(md_file, "r+", encoding="UTF-8") as f:
37-
all_text = f.read()
38-
if github_uri not in all_text:
39-
print(f"将 {md_file} 中的本地图片路径替换为GitHub在线路径")
40-
all_text_new = all_text.replace(md_uri, github_uri)
41-
else:
42-
print(f"将 {md_file} 中的GitHub在线路径替换为本地图片路径")
43-
all_text_new = all_text.replace(github_uri, md_uri)
44-
f.seek(0)
45-
f.write(all_text_new)
46-
# FIXME 会在文件尾部多出来莫名其妙的行
47-
48-
49-
def compile_resources() -> int:
50-
"""调用 RCC 工具编译静态资源
51-
52-
:return: rcc 进程返回码
53-
"""
54-
55-
compiled_file_path = RESOURCES_PATH / "COMPILED_RESOURCES.py"
56-
qrc_file_path = RESOURCES_PATH / "resources.qrc"
57-
cmd = [
58-
"pyside6-rcc",
59-
"-o",
60-
str(compiled_file_path.absolute()),
61-
str(qrc_file_path.absolute()),
62-
]
63-
try:
64-
result = subprocess.run(cmd)
65-
except subprocess.SubprocessError as e:
66-
print(f"RCC编译进程错误:{e}")
67-
raise e
68-
else:
69-
print(f"已完成静态资源文件编译,RCC返回码:{result.returncode}。")
70-
return result.returncode
13+
from dev_scripts.path_constants import PROJECT_ROOT, SRC_PATH
7114

7215

7316
def export_requirements() -> int:
@@ -102,23 +45,26 @@ def build_py2exe_gui() -> None:
10245
# 准备工作
10346
clear_pyinstaller_dist(SRC_PATH)
10447
clear_pycache(SRC_PATH)
105-
process_md_images(README_FILE_LIST)
10648
# compile_resources()
10749
export_requirements()
10850
print(f"pre-commit 检查完毕,返回码:{check_pre_commit()}。")
10951
print(f"mypy 检查完毕,返回码:{check_mypy()}。")
11052

11153
# 正式构建
112-
subprocess.run(["poetry", "build"]) # TODO 处理异常与返回值
113-
114-
# 清理
115-
process_md_images(README_FILE_LIST)
54+
try:
55+
result = subprocess.run(["poetry", "build"], check=True)
56+
except subprocess.SubprocessError as e:
57+
print(f"Poetry build 失败:{e}")
58+
raise
59+
else:
60+
print(f"Poetry build 完毕,返回码:{result.returncode}。")
61+
finally:
62+
# 清理
63+
pass
11664
else:
117-
print("构建失败,有未通过的检查项")
65+
print("有未通过的检查项,不进行构建")
11866

11967

12068
if __name__ == "__main__":
121-
# process_md_images()
122-
# compile_resources()
12369
# export_requirements()
12470
build_py2exe_gui()

dev_scripts/path_constants.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
"""
2-
开发脚本中使用的相对路径常量
1+
"""开发脚本中使用的相对路径常量
2+
33
所有脚本应以项目根目录为工作目录运行
44
"""
55

66
from pathlib import Path
77

8-
PROJECT_ROOT = Path("../") # 项目根目录
8+
PROJECT_ROOT = Path(__file__).parent.parent # 项目根目录
99
SRC_PATH = PROJECT_ROOT / "src" # 源码目录
10-
SRC_PKG_PATH = SRC_PATH / "py2exe_gui"
10+
SRC_PKG_PATH = SRC_PATH / "py2exe_gui" # 包目录
1111
RESOURCES_PATH = SRC_PKG_PATH / "Resources" # 静态资源文件目录
1212
COMPILED_RESOURCES = RESOURCES_PATH / "COMPILED_RESOURCES.py" # 编译静态资源文件
13+
WIDGETS_PATH = SRC_PKG_PATH / "Widgets" # 控件目录
1314
README_FILE_LIST = [
1415
PROJECT_ROOT / "README.md",
1516
PROJECT_ROOT / "README_zh.md",
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""开发脚本,便于调用 PySide6 提供的各种工具程序
2+
"""
3+
4+
import subprocess
5+
6+
from dev_scripts.path_constants import (
7+
COMPILED_RESOURCES,
8+
PROJECT_ROOT,
9+
RESOURCES_PATH,
10+
SRC_PKG_PATH,
11+
WIDGETS_PATH,
12+
)
13+
14+
15+
def compile_resources() -> int:
16+
"""调用 RCC 工具编译静态资源
17+
18+
:return: rcc 进程返回码
19+
"""
20+
21+
compiled_file_path = COMPILED_RESOURCES
22+
qrc_file_path = RESOURCES_PATH / "resources.qrc"
23+
cmd = [
24+
"pyside6-rcc",
25+
"-o",
26+
compiled_file_path,
27+
qrc_file_path,
28+
]
29+
30+
try:
31+
result = subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
32+
except subprocess.SubprocessError as e:
33+
print(f"RCC 编译进程错误:{e}")
34+
raise e
35+
else:
36+
print(f"已完成静态资源文件编译,RCC 返回码:{result.returncode}。")
37+
return result.returncode
38+
39+
40+
def gen_ts(lang: str = "zh_CN") -> int:
41+
"""调用 lupdate 工具分析源码,生成 .ts 文本翻译文件
42+
43+
:param lang: 目标翻译语言代码
44+
:return: lupdate 返回码
45+
"""
46+
47+
source = [*list(WIDGETS_PATH.glob("**/*.py")), SRC_PKG_PATH / "__main__.py"]
48+
target = RESOURCES_PATH / "i18n" / f"{lang.replace('-', '_')}.ts"
49+
cmd = ["pyside6-lupdate", *source, "-ts", target]
50+
51+
try:
52+
result = subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
53+
except subprocess.SubprocessError as e:
54+
print(f"lupdate 进程错误:{e}")
55+
raise
56+
else:
57+
print(f"已完成文本翻译文件生成,lupdate 返回码:{result.returncode}。")
58+
return result.returncode
59+
60+
61+
def gen_qm(lang: str = "zh_CN") -> int:
62+
"""调用 lrelease 工具编译.ts 文本翻译文件
63+
64+
:param lang: 目标翻译语言代码
65+
:return: lrelease 返回码
66+
"""
67+
68+
source = RESOURCES_PATH / "i18n" / f"{lang.replace('-', '_')}.ts"
69+
target = RESOURCES_PATH / "i18n" / f"{lang.replace('-', '_')}.qm"
70+
cmd = ["pyside6-lrelease", source, "-qm", target]
71+
72+
try:
73+
result = subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
74+
except subprocess.SubprocessError as e:
75+
print(f"lrelease 进程错误:{e}")
76+
raise
77+
else:
78+
print(f"已完成文本翻译文件编译,lrelease 返回码:{result.returncode}。")
79+
return result.returncode
80+
81+
82+
if __name__ == "__main__":
83+
# compile_resources()
84+
gen_ts("zh_CN")
85+
# gen_qm("zh_CN")
25.4 KB
Loading

poetry.lock

Lines changed: 27 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[tool.poetry]
22
name = "py2exe-gui"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
description = "GUI for PyInstaller, based on PySide6"
55
keywords = ["PyInstaller", "GUI", "PySide6"]
66
authors = ["muzing <muzi2001@foxmail.com>"]
77
license = "GPL-3.0-or-later"
88
readme = ["README.md", "README_zh.md"]
99
repository = "https://github.com/muziing/Py2exe-GUI"
10-
exclude = ["src/py2exe_gui/Resources/Icons", "src/py2exe_gui/Resources/Texts"]
10+
exclude = ["src/py2exe_gui/Resources"]
11+
include = ["src/py2exe_gui/Resources/COMPILED_RESOURCES.py"]
1112
classifiers = [
1213
"Development Status :: 4 - Beta",
1314
"Operating System :: Microsoft :: Windows",
@@ -32,12 +33,11 @@ PySide6 = "^6.6.0"
3233
pyyaml = "^6.0.1"
3334

3435
[tool.poetry.group.dev]
35-
3636
[tool.poetry.group.dev.dependencies]
3737
pre-commit = "^3.5.0"
3838
black = "^23.12.0"
3939
isort = "^5.13.0"
40-
ruff = "^0.1.9"
40+
ruff = "^0.1.11"
4141
mypy = "^1.8.0"
4242
pyinstaller = "^6.2.0"
4343
types-pyyaml = "^6.0.12.12"

0 commit comments

Comments
 (0)