Skip to content

Commit

Permalink
Merge pull request #20 from muziing/dev
Browse files Browse the repository at this point in the history
Version `0.3.1`
  • Loading branch information
muziing committed Jan 4, 2024
2 parents 5f3bc8b + 09f6533 commit 35e24cb
Show file tree
Hide file tree
Showing 29 changed files with 1,502 additions and 303 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Py2exe-GUI Logo](docs/source/images/py2exe-gui_logo_big.png)
![Py2exe-GUI Logo](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png)

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

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

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

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

It has the following features:

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

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

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

## License

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

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

Expand Down
8 changes: 4 additions & 4 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Py2exe-GUI Logo](docs/source/images/py2exe-gui_logo_big.png)
![Py2exe-GUI Logo](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png)

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

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

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

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

有如下特性:

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

## 开源许可

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

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

Expand Down
78 changes: 12 additions & 66 deletions dev_scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""

import subprocess
from pathlib import Path

from dev_scripts.check_funcs import (
check_license_statement,
Expand All @@ -11,63 +10,7 @@
check_version_num,
)
from dev_scripts.clear_cache import clear_pycache, clear_pyinstaller_dist
from dev_scripts.path_constants import (
PROJECT_ROOT,
README_FILE_LIST,
RESOURCES_PATH,
SRC_PATH,
)


def process_md_images(md_file_list: list[Path]) -> None:
"""处理 Markdown 文档中的图片链接
在构建前替换为 GitHub 图床链接,在构建后替换回本地目录中的路径
:param md_file_list: Markdown 文件列表
"""

md_uri = "docs/source/images/"
github_uri = (
"https://github.com/muziing/Py2exe-GUI/raw/main" + "/docs/source/images/"
)

for md_file in md_file_list:
with open(md_file, "r+", encoding="UTF-8") as f:
all_text = f.read()
if github_uri not in all_text:
print(f"将 {md_file} 中的本地图片路径替换为GitHub在线路径")
all_text_new = all_text.replace(md_uri, github_uri)
else:
print(f"将 {md_file} 中的GitHub在线路径替换为本地图片路径")
all_text_new = all_text.replace(github_uri, md_uri)
f.seek(0)
f.write(all_text_new)
# FIXME 会在文件尾部多出来莫名其妙的行


def compile_resources() -> int:
"""调用 RCC 工具编译静态资源
:return: rcc 进程返回码
"""

compiled_file_path = RESOURCES_PATH / "COMPILED_RESOURCES.py"
qrc_file_path = RESOURCES_PATH / "resources.qrc"
cmd = [
"pyside6-rcc",
"-o",
str(compiled_file_path.absolute()),
str(qrc_file_path.absolute()),
]
try:
result = subprocess.run(cmd)
except subprocess.SubprocessError as e:
print(f"RCC编译进程错误:{e}")
raise e
else:
print(f"已完成静态资源文件编译,RCC返回码:{result.returncode}。")
return result.returncode
from dev_scripts.path_constants import PROJECT_ROOT, SRC_PATH


def export_requirements() -> int:
Expand Down Expand Up @@ -102,23 +45,26 @@ def build_py2exe_gui() -> None:
# 准备工作
clear_pyinstaller_dist(SRC_PATH)
clear_pycache(SRC_PATH)
process_md_images(README_FILE_LIST)
# compile_resources()
export_requirements()
print(f"pre-commit 检查完毕,返回码:{check_pre_commit()}。")
print(f"mypy 检查完毕,返回码:{check_mypy()}。")

# 正式构建
subprocess.run(["poetry", "build"]) # TODO 处理异常与返回值

# 清理
process_md_images(README_FILE_LIST)
try:
result = subprocess.run(["poetry", "build"], check=True)
except subprocess.SubprocessError as e:
print(f"Poetry build 失败:{e}")
raise
else:
print(f"Poetry build 完毕,返回码:{result.returncode}。")
finally:
# 清理
pass
else:
print("构建失败,有未通过的检查项")
print("有未通过的检查项,不进行构建")


if __name__ == "__main__":
# process_md_images()
# compile_resources()
# export_requirements()
build_py2exe_gui()
9 changes: 5 additions & 4 deletions dev_scripts/path_constants.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""
开发脚本中使用的相对路径常量
"""开发脚本中使用的相对路径常量
所有脚本应以项目根目录为工作目录运行
"""

from pathlib import Path

PROJECT_ROOT = Path("../") # 项目根目录
PROJECT_ROOT = Path(__file__).parent.parent # 项目根目录
SRC_PATH = PROJECT_ROOT / "src" # 源码目录
SRC_PKG_PATH = SRC_PATH / "py2exe_gui"
SRC_PKG_PATH = SRC_PATH / "py2exe_gui" # 包目录
RESOURCES_PATH = SRC_PKG_PATH / "Resources" # 静态资源文件目录
COMPILED_RESOURCES = RESOURCES_PATH / "COMPILED_RESOURCES.py" # 编译静态资源文件
WIDGETS_PATH = SRC_PKG_PATH / "Widgets" # 控件目录
README_FILE_LIST = [
PROJECT_ROOT / "README.md",
PROJECT_ROOT / "README_zh.md",
Expand Down
85 changes: 85 additions & 0 deletions dev_scripts/pyside6_tools_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""开发脚本,便于调用 PySide6 提供的各种工具程序
"""

import subprocess

from dev_scripts.path_constants import (
COMPILED_RESOURCES,
PROJECT_ROOT,
RESOURCES_PATH,
SRC_PKG_PATH,
WIDGETS_PATH,
)


def compile_resources() -> int:
"""调用 RCC 工具编译静态资源
:return: rcc 进程返回码
"""

compiled_file_path = COMPILED_RESOURCES
qrc_file_path = RESOURCES_PATH / "resources.qrc"
cmd = [
"pyside6-rcc",
"-o",
compiled_file_path,
qrc_file_path,
]

try:
result = subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
except subprocess.SubprocessError as e:
print(f"RCC 编译进程错误:{e}")
raise e
else:
print(f"已完成静态资源文件编译,RCC 返回码:{result.returncode}。")
return result.returncode


def gen_ts(lang: str = "zh_CN") -> int:
"""调用 lupdate 工具分析源码,生成 .ts 文本翻译文件
:param lang: 目标翻译语言代码
:return: lupdate 返回码
"""

source = [*list(WIDGETS_PATH.glob("**/*.py")), SRC_PKG_PATH / "__main__.py"]
target = RESOURCES_PATH / "i18n" / f"{lang.replace('-', '_')}.ts"
cmd = ["pyside6-lupdate", *source, "-ts", target]

try:
result = subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
except subprocess.SubprocessError as e:
print(f"lupdate 进程错误:{e}")
raise
else:
print(f"已完成文本翻译文件生成,lupdate 返回码:{result.returncode}。")
return result.returncode


def gen_qm(lang: str = "zh_CN") -> int:
"""调用 lrelease 工具编译.ts 文本翻译文件
:param lang: 目标翻译语言代码
:return: lrelease 返回码
"""

source = RESOURCES_PATH / "i18n" / f"{lang.replace('-', '_')}.ts"
target = RESOURCES_PATH / "i18n" / f"{lang.replace('-', '_')}.qm"
cmd = ["pyside6-lrelease", source, "-qm", target]

try:
result = subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
except subprocess.SubprocessError as e:
print(f"lrelease 进程错误:{e}")
raise
else:
print(f"已完成文本翻译文件编译,lrelease 返回码:{result.returncode}。")
return result.returncode


if __name__ == "__main__":
# compile_resources()
gen_ts("zh_CN")
# gen_qm("zh_CN")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 27 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[tool.poetry]
name = "py2exe-gui"
version = "0.3.0"
version = "0.3.1"
description = "GUI for PyInstaller, based on PySide6"
keywords = ["PyInstaller", "GUI", "PySide6"]
authors = ["muzing <muzi2001@foxmail.com>"]
license = "GPL-3.0-or-later"
readme = ["README.md", "README_zh.md"]
repository = "https://github.com/muziing/Py2exe-GUI"
exclude = ["src/py2exe_gui/Resources/Icons", "src/py2exe_gui/Resources/Texts"]
exclude = ["src/py2exe_gui/Resources"]
include = ["src/py2exe_gui/Resources/COMPILED_RESOURCES.py"]
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: Microsoft :: Windows",
Expand All @@ -32,12 +33,11 @@ PySide6 = "^6.6.0"
pyyaml = "^6.0.1"

[tool.poetry.group.dev]

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.5.0"
black = "^23.12.0"
isort = "^5.13.0"
ruff = "^0.1.9"
ruff = "^0.1.11"
mypy = "^1.8.0"
pyinstaller = "^6.2.0"
types-pyyaml = "^6.0.12.12"
Expand Down
Loading

0 comments on commit 35e24cb

Please sign in to comment.