mirror of
https://github.com/muziing/Py2exe-GUI.git
synced 2025-01-13 16:42:54 +08:00
Merge branch 'dev'
This commit is contained in:
commit
02f9bd4919
97
.github/CONTRIBUTING.md
vendored
Normal file
97
.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
# Contributing
|
||||
|
||||
> 简体中文版本在本文档下方。
|
||||
|
||||
Thank you very much for your willingness to contribute to the Py2exe-GUI project, please read the following and follow
|
||||
some ground rules in order to keep the project in good shape for rapid development.
|
||||
|
||||
## Before Writing Code
|
||||
|
||||
If you have any thoughts that involve more than a few dozen lines of code, I highly recommend you to submit an issue first talking about the stuff you want to implement. It's a good idea to discuss whether we want to do it before you put a lot of effort into it, and it also ensures that we're not duplicating work.
|
||||
|
||||
## Coding
|
||||
|
||||
### Prepare the development environment
|
||||
|
||||
Development environment is more complicated than use environment, ensure that you have installed Python 3.11+ and [Poetry](https://python-poetry.org/docs/#installation). Then use Poetry to create and install the development environment:
|
||||
|
||||
```shell
|
||||
cd Py2exe-GUI
|
||||
poetry init
|
||||
poetry install
|
||||
```
|
||||
|
||||
You also need to install a git hook via [pre-commit](https://pre-commit.com/):
|
||||
|
||||
```shell
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
### Code Style
|
||||
|
||||
- In general, new and modified code should be close to the style of the original code. Try to make the code readable.
|
||||
- Please format the code using [Black](https://black.readthedocs.io/en/stable/) to ensure that all code styles are consistent with the project.
|
||||
- Please add sufficient type annotations to the code for your code. This allows the code to pass [mypy](https://mypy.readthedocs.io/en/stable/) checks without reporting errors.
|
||||
- Please add docstrings or comments to modules, classes, functions/methods, properties, etc. to ensure clarity and readability.
|
||||
|
||||
### Documentation
|
||||
|
||||
If you implement some new features, you should consider adding the appropriate documentation to the `docs/` directory, or modifying `README.md` as appropriate to elaborate.
|
||||
|
||||
### Tests
|
||||
|
||||
The Py2exe-GUI project does not have any tests at the moment due to my limited programming skills as well as the fact that automated tests are not easily implemented for GUI programs. If you want to add some test code, please create `tests/` directory in the root directory of the whole project and put the test code in it.
|
||||
|
||||
## Pull Request
|
||||
|
||||
Do a pull request to the `main` branch of [muziing/Py2exe-GUI](https://github.com/muziing/Py2exe-GUI), and I will review the code and give feedbacks as soon as possible.
|
||||
|
||||
-----
|
||||
|
||||
# 贡献指南
|
||||
|
||||
非常感谢你愿意为 Py2exe-GUI 项目提供贡献,请阅读以下内容,遵守一些基本规则,以便项目保持良好状态快速发展。
|
||||
|
||||
## 开始编码之前
|
||||
|
||||
如果你准备对代码进行超过数十行的修改或新增,我强烈建议你先提交一个 issue,谈谈你想实现的东西。在投入很多精力之前,我们应该先讨论一下是否要这样做,也可以确保我们不重复工作。
|
||||
|
||||
## 编写代码
|
||||
|
||||
### 准备开发环境
|
||||
|
||||
开发环境相较于使用环境较为复杂,确保已经安装 Python 3.11+ 和 [Poetry](https://python-poetry.org/docs/#installation),然后通过 Poetry 创建和安装开发环境:
|
||||
|
||||
```shell
|
||||
cd Py2exe-GUI
|
||||
poetry init
|
||||
poetry install
|
||||
```
|
||||
|
||||
> 如果你在国内使用 PyPI 源速度较慢,可以考虑取消注释 `pyproject.toml` 文件中的 `[[tool.poetry.source]]`
|
||||
> 小节,启用国内镜像站。但注意不要将修改后的 `poetry.lock` 文件提交到 git 中。
|
||||
|
||||
还需要通过 [pre-commit](https://pre-commit.com/) 安装 git 钩子:
|
||||
|
||||
```shell
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
### 代码风格
|
||||
|
||||
- 总体来讲,新增和修改的代码应接近原有代码的风格。尽量使代码有良好的可读性。
|
||||
- 请使用 [Black](https://black.readthedocs.io/en/stable/) 格式化代码,确保所有代码风格与项目一致。开发环境中已经安装了 Black,配置使用方法可以参考[这篇文章](https://muzing.top/posts/a29e4743/)。
|
||||
- 请为代码添加充分的[类型注解](https://muzing.top/posts/84a8da1c/),并能通过 [mypy](https://mypy.readthedocs.io/en/stable/) 检查不报错。
|
||||
- 请为模块、类、函数/方法、属性等添加 docstring 或注释,确保含义清晰易读。
|
||||
|
||||
### 文档
|
||||
|
||||
如果你实现了一些新功能,应考虑在 `docs/` 目录下添加相应的文档,或适当修改 `README.md` 来加以阐述。
|
||||
|
||||
### 测试
|
||||
|
||||
由于我的编程水平有限、GUI 程序不易实现自动化测试等原因,Py2exe-GUI 项目暂无测试。如果你想添加一些测试代码,请在整个项目的根目录下创建 `tests/` 目录,并将测试代码置于其中。
|
||||
|
||||
## 拉取请求
|
||||
|
||||
新建一个指向 [muziing/Py2exe-GUI](https://github.com/muziing/Py2exe-GUI) 的 `main` 分支的拉取请求,我将尽快 review`muziing/Py2exe-GUI` 的 `main` 分支的拉取请求,我将尽快 review 代码并给出反馈。
|
24
README.md
24
README.md
@ -1,6 +1,8 @@
|
||||
![Py2exe-GUI Logo](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png)
|
||||
<p align="center">
|
||||
<img alt="Py2exe-GUI Logo" src="https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png">
|
||||
</p>
|
||||
|
||||
<h2 align="center">Easy-to-use Python GUI packaging tool</h2>
|
||||
<h2 align="center">Python GUI packaging tool</h2>
|
||||
|
||||
<p align="center">
|
||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/muziing/Py2exe-GUI">
|
||||
@ -32,8 +34,7 @@ It has the following features:
|
||||
|
||||
- Fully graphical interface, easy to use.
|
||||
- All options of PyInstaller will be supported.
|
||||
- You can invoke any local Python interpreter with its corresponding environment, eliminating the need to reinstall it
|
||||
in each interpreter environment to be packaged.
|
||||
- You can invoke any local Python interpreter with its corresponding environment, eliminating the need to reinstall it in each interpreter environment to be packaged.
|
||||
- Cross-platform, supports Windows, Linux and macOS.
|
||||
|
||||
## How to install
|
||||
@ -69,8 +70,7 @@ python -m py2exe_gui # `_`, not `-`
|
||||
|
||||
### Option B: Run through source code
|
||||
|
||||
For those who like to try it out or are in desperate need of the latest bug fixes, you can run it through the repository
|
||||
source code:
|
||||
For those who like to try it out or are in desperate need of the latest bug fixes, you can run it through the repository source code:
|
||||
|
||||
1. Download the [latest main branching source code](https://codeload.github.com/muziing/Py2exe-GUI/zip/refs/heads/main).
|
||||
|
||||
@ -97,13 +97,9 @@ source code:
|
||||
|
||||
Py2exe-GUI is a free and open source software and anyone is welcome to contribute to its development.
|
||||
|
||||
If you encounter any problems while using it (including
|
||||
bugs, typos, etc.), or if you have suggestions for new features, you can open
|
||||
an [issue](https://github.com/muziing/Py2exe-GUI/issues/new).
|
||||
If you encounter any problems while using it (including bugs, typos, etc.), or if you have suggestions for new features, you can open an [issue](https://github.com/muziing/Py2exe-GUI/issues/new).
|
||||
|
||||
If you are able to contribute code, feel free to submit a pull-request.
|
||||
Please follow the original code style as much as possible, and make sure that the new code passes all
|
||||
the [checks](dev_scripts/check_funcs.py).
|
||||
If you have the willingness and ability to contribute code, please read the [contribution guidance](.github/CONTRIBUTING.md) for more details.
|
||||
|
||||
## License
|
||||
|
||||
@ -111,9 +107,7 @@ the [checks](dev_scripts/check_funcs.py).
|
||||
|
||||
Py2exe-GUI is licensed under the GPLv3 open source license, see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
There is one exception: if your project uses Py2exe-GUI only as a packaging tool, and your final distribution does not
|
||||
contain Py2exe-GUI's source code or binaries, then your project is not restricted by the GPLv3 restrictions and can
|
||||
still be distributed as closed-source commercial software.
|
||||
There is one exception: if your project uses Py2exe-GUI only as a packaging tool, and your final distribution does not contain Py2exe-GUI's source code or binaries, then your project is not restricted by the GPLv3 restrictions and can still be distributed as closed-source commercial software.
|
||||
|
||||
```text
|
||||
Py2exe-GUI
|
||||
|
16
README_zh.md
16
README_zh.md
@ -1,4 +1,6 @@
|
||||
![Py2exe-GUI Logo](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png)
|
||||
<p align="center">
|
||||
<img alt="Py2exe-GUI Logo" src="https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/py2exe-gui_logo_big.png">
|
||||
</p>
|
||||
|
||||
<h2 align="center">强大易用的 Python 图形界面打包工具</h2>
|
||||
|
||||
@ -20,8 +22,7 @@
|
||||
|
||||
## 简介
|
||||
|
||||
Py2exe-GUI 是一个基于 [PySide6](https://doc.qt.io/qtforpython/index.html)
|
||||
开发的辅助工具,旨在为 [PyInstaller](https://pyinstaller.org/) 提供完整易用的图形化界面,方便用户进行 Python 项目的打包。
|
||||
Py2exe-GUI 是一个基于 [PySide6](https://doc.qt.io/qtforpython/index.html) 开发的辅助工具,旨在为 [PyInstaller](https://pyinstaller.org/) 提供完整易用的图形化界面,方便用户进行 Python 项目的打包。
|
||||
|
||||
![界面截图](https://raw.githubusercontent.com/muziing/Py2exe-GUI/main/docs/source/images/Py2exe-GUI_v0.3.0_mainwindow_screenshot.png)
|
||||
|
||||
@ -93,11 +94,9 @@ python -m py2exe_gui # 注意连字符为_
|
||||
|
||||
Py2exe-GUI 是一个自由的开源软件,欢迎任何人为其开发贡献力量。
|
||||
|
||||
如果你在使用时遇到任何问题(包括
|
||||
bug、界面错别字等),或者提议新增实用功能,可以提交一个 [issue](https://github.com/muziing/Py2exe-GUI/issues/new)。
|
||||
如果你在使用时遇到任何问题(包括 bug、界面错别字等),或者提议新增实用功能,可以提交一个 [issue](https://github.com/muziing/Py2exe-GUI/issues/new)。
|
||||
|
||||
如果你有能力有想法贡献代码,欢迎提交 pull
|
||||
request。请尽可能遵守原有的代码风格,并确保新增代码能通过[静态检查](dev_scripts/check_funcs.py)。
|
||||
如果你有能力有想法贡献代码,请阅读[贡献指南](.github/CONTRIBUTING.md)了解更多详情。
|
||||
|
||||
## 开源许可
|
||||
|
||||
@ -105,8 +104,7 @@ request。请尽可能遵守原有的代码风格,并确保新增代码能通
|
||||
|
||||
Py2exe-GUI 采用 GPLv3 开源许可证,详情请参见 [LICENSE](LICENSE) 文件。
|
||||
|
||||
但有一个例外:如果你的项目仅使用 Py2exe-GUI 作为打包工具,而最终发布的软件中并不包含 Py2exe-GUI 的源码或二进制文件,那么你的项目不会受到
|
||||
GPLv3 的限制,仍可作为闭源商业软件发布。
|
||||
但有一个例外:如果你的项目仅使用 Py2exe-GUI 作为打包工具,而最终发布的软件中并不包含 Py2exe-GUI 的源码或二进制文件,那么你的项目不会受到 GPLv3 的限制,仍可作为闭源商业软件发布。
|
||||
|
||||
```text
|
||||
Py2exe-GUI
|
||||
|
@ -1,6 +1,11 @@
|
||||
"""用于构建项目的脚本
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
"export_requirements",
|
||||
"build_py2exe_gui",
|
||||
]
|
||||
|
||||
import subprocess
|
||||
|
||||
from dev_scripts.check_funcs import (
|
||||
@ -46,7 +51,7 @@ def build_py2exe_gui() -> None:
|
||||
clear_pyinstaller_dist(SRC_PATH)
|
||||
clear_pycache(SRC_PATH)
|
||||
# compile_resources()
|
||||
export_requirements()
|
||||
# export_requirements()
|
||||
print(f"pre-commit 检查完毕,返回码:{check_pre_commit()}。")
|
||||
print(f"mypy 检查完毕,返回码:{check_mypy()}。")
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
"""各类检查函数
|
||||
"""
|
||||
各类检查函数
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
"check_license_statement",
|
||||
"check_version_num",
|
||||
"check_pre_commit",
|
||||
"check_mypy",
|
||||
]
|
||||
|
||||
import subprocess
|
||||
import tomllib
|
||||
@ -17,8 +23,8 @@ from py2exe_gui import __version__ as py2exe_gui__version__
|
||||
|
||||
|
||||
def check_license_statement() -> int:
|
||||
"""
|
||||
检查源代码文件中是否都包含了许可声明
|
||||
"""检查源代码文件中是否都包含了许可声明
|
||||
|
||||
:return: 0-所有源文件都包含许可声明;1-存在缺失许可声明的源文件
|
||||
"""
|
||||
|
||||
@ -46,8 +52,8 @@ def check_license_statement() -> int:
|
||||
|
||||
|
||||
def check_version_num() -> int:
|
||||
"""
|
||||
检查各部分声明的版本号是否一致 \n
|
||||
"""检查各部分声明的版本号是否一致
|
||||
|
||||
:return: 0-各处版本一致;1-存在版本不一致情况
|
||||
"""
|
||||
|
||||
@ -74,8 +80,10 @@ def check_version_num() -> int:
|
||||
|
||||
|
||||
def check_pre_commit() -> int:
|
||||
"""
|
||||
调用已有的 pre-commit 检查工具进行检查 \n
|
||||
"""调用已有的 pre-commit 检查工具进行检查
|
||||
|
||||
如果首次调用返回值不为0,可能已经进行了一定的自动修复,需要再运行第二次检查返回值
|
||||
|
||||
:return: pre-commit 进程返回码
|
||||
"""
|
||||
|
||||
@ -86,7 +94,7 @@ def check_pre_commit() -> int:
|
||||
print("开始进行第二次 pre-commit 检查...")
|
||||
result_2 = subprocess.run(pre_commit_run_cmd)
|
||||
if result_2.returncode != 0:
|
||||
warnings.warn("pre-commit进程返回码非0,建议检查", stacklevel=1)
|
||||
warnings.warn("pre-commit 进程返回码非 0,建议检查", stacklevel=1)
|
||||
return result_2.returncode
|
||||
else:
|
||||
print("pre-commit 检查完成,所有项目通过。")
|
||||
@ -94,16 +102,18 @@ def check_pre_commit() -> int:
|
||||
|
||||
|
||||
def check_mypy() -> int:
|
||||
"""
|
||||
调用mypy进行静态代码分析
|
||||
"""
|
||||
"""调用mypy进行静态代码分析"""
|
||||
|
||||
mypy_cmd = ["mypy", SRC_PKG_PATH, "--config-file", PROJECT_ROOT / "pyproject.toml"]
|
||||
print("开始运行 mypy 检查...")
|
||||
result = subprocess.run(mypy_cmd)
|
||||
print("mypy 检查运行完毕。")
|
||||
|
||||
return result.returncode
|
||||
try:
|
||||
result = subprocess.run(mypy_cmd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
warnings.warn(f"mypy 检查失败,错误信息:{e}", stacklevel=1)
|
||||
return e.returncode
|
||||
else:
|
||||
print("mypy 检查运行完毕。")
|
||||
return result.returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,6 +1,11 @@
|
||||
"""各种清理函数,如清理 Python 编译缓存、PyInstaller 打包中间文件与输出文件等
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
"clear_pyinstaller_dist",
|
||||
"clear_pycache",
|
||||
]
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from shutil import rmtree
|
||||
@ -9,14 +14,15 @@ from dev_scripts.path_constants import SRC_PATH
|
||||
|
||||
|
||||
def clear_pyinstaller_dist(src_path: Path) -> None:
|
||||
"""
|
||||
清理开发过程中测试运行时的打包中间文件及结果文件 \n
|
||||
"""清理开发过程中测试运行时的打包中间文件及结果文件
|
||||
|
||||
:param src_path: Py2exe-GUI.py 运行目录
|
||||
"""
|
||||
|
||||
dist_path = src_path / Path("dist")
|
||||
build_path = src_path / Path("build")
|
||||
dist_path = src_path / "dist"
|
||||
build_path = src_path / "build"
|
||||
spec_path_list = list(src_path.glob("*.spec"))
|
||||
|
||||
if dist_path.exists():
|
||||
rmtree(dist_path)
|
||||
if build_path.exists():
|
||||
@ -24,13 +30,15 @@ def clear_pyinstaller_dist(src_path: Path) -> None:
|
||||
if spec_path_list:
|
||||
for spec_file in spec_path_list:
|
||||
os.remove(spec_file)
|
||||
print("Pyinstaller dist all cleaned.")
|
||||
|
||||
print("Pyinstaller dist and cache all cleaned.")
|
||||
|
||||
|
||||
def clear_pycache(src_path: Path) -> None:
|
||||
"""
|
||||
清理给定路径下的所有 .pyc .pyo 文件与 __pycache__ 目录 \n
|
||||
"""清理给定路径下的所有 `.pyc` `.pyo` 文件与 `__pycache__` 目录
|
||||
|
||||
ref: https://stackoverflow.com/a/41386937
|
||||
|
||||
:param src_path: 源码 src 目录路径
|
||||
"""
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
"""开发脚本,便于调用 PySide6 提供的各种工具程序
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
"compile_resources",
|
||||
"gen_ts",
|
||||
"gen_qm",
|
||||
]
|
||||
|
||||
import subprocess
|
||||
|
||||
from dev_scripts.path_constants import (
|
||||
|
@ -1,14 +1,23 @@
|
||||
# 开发待办事项
|
||||
|
||||
此文档用于记录灵感,内容格式较为随意。其中的大部分功能将会逐渐实现,也有部分可能会被删去。
|
||||
|
||||
如果你对 Py2exe-GUI 的新功能有建议,欢迎[提交 issue](https://github.com/muziing/Py2exe-GUI/issues/new)。
|
||||
|
||||
## 控件
|
||||
|
||||
- [ ] 子进程窗口 `SubProcessDlg`
|
||||
- [ ] PyInstaller 子进程窗口 `SubProcessDlg`
|
||||
- [x] 将子进程的输出与状态显示至单独的对话框
|
||||
- [x] 增加多功能按钮
|
||||
- [x] 关闭窗口时中断子进程、清除输出
|
||||
- [x] 处理不能正确显示子进程错误的问题(会被“打包完成”遮盖)
|
||||
- [ ] 增加「将输出导出到日志文件」功能
|
||||
- [ ] 增加简单高亮功能
|
||||
- [x] 命令浏览器
|
||||
- [x] 显示将传递给 PyInstaller 的选项列表
|
||||
- [x] 高亮提示
|
||||
- [x] 以终端命令格式显示完整命令,并添加续行符
|
||||
- [ ] 导出为脚本功能,根据运行时平台导出 bash、PowerShell 等格式脚本
|
||||
- [x] 添加资源文件窗口
|
||||
- [x] `--add-data`、 `--add-binary`
|
||||
- [x] `--paths`、`--hidden-import` 等可多次调用的选项
|
||||
@ -18,38 +27,35 @@
|
||||
- [x] 处理解释器验证器返回结果,异常时弹出对话框要求用户自行检查确认
|
||||
- [x] 创建「解释器环境类」,保存解释器路径等信息
|
||||
- [x] ComboBox 中列出各解释器,将解释器环境保存在全局变量 ALL_PY_ENVs 中
|
||||
- [ ] 识别是否已安装 `PyInstaller`,未安装则提供「一键安装」
|
||||
- [x] 识别 系统解释器/venv/Poetry/conda 等
|
||||
- [ ] 识别是否已安装 `PyInstaller`,未安装则提供「一键安装」
|
||||
- [ ] 右键菜单,可以将现有的环境 pin(固定),并保存到缓存文件中,后续启动时自动加载
|
||||
- [ ] 用户自定义选项输入框
|
||||
- [ ] 允许用户自行输入选项,添加到选项列表中
|
||||
- [x] 命令浏览器
|
||||
- [x] 显示将传递给 PyInstaller 的选项列表
|
||||
- [x] 高亮提示
|
||||
- [x] 以终端命令格式显示完整命令,并添加续行符
|
||||
- [ ] 导出为脚本功能,根据运行时平台导出 bash、PowerShell 等格式脚本
|
||||
- [x] ToolTip 提示,对应 PyInstaller 文档,提供完整帮助信息
|
||||
- [x] `PyInstaller` 选项参数详解表格(界面细节待优化)
|
||||
- [x] 主窗口状态栏显示软件版本
|
||||
- [ ] 「一键调试」模式,自动选择 `--onedir`、`--console`、`--debug` 等利于调试的选项
|
||||
- [ ] 用户设置窗口:若干个选项卡
|
||||
- [ ] 界面语言
|
||||
- [ ] PyInstaller 选项
|
||||
- [ ] 导入/导出选项
|
||||
- [ ] 插件(比如 Pillow 是否已安装)
|
||||
- [ ] 插件(比如 Pillow 是否已安装、UPX 是否可用等)
|
||||
- [ ] 简洁视图(仅包含常用选项)/详细视图(包含所有 PyInstaller 可用选项) 切换
|
||||
|
||||
## 打包
|
||||
|
||||
- [x] 选项参数获取
|
||||
- [x] 将参数拼接成完整调用命令
|
||||
- [x] 参数预览器控件
|
||||
- [x] 使用枚举值控制参数
|
||||
- [x] 优化拼接代码
|
||||
- [x] 调用 `PyInstaller` 子进程
|
||||
- [x] 使用 Python 解释器直接运行命令,而不是 `PyInstaller.exe`
|
||||
- [x] 使用 `QProcess` 替代 `subprocess` 以解决界面卡死问题
|
||||
- [x] 优化子进程相关代码,增强异常处理
|
||||
- [ ] 打包任务
|
||||
- [x] 创建打包任务,保存所有选项
|
||||
- [ ] 导出打包任务(json 或 yaml 格式)与加载打包任务(与Auto-py-to-exe兼容)
|
||||
- [ ] 导出打包任务(json 或 yaml 格式)与加载打包任务(与 [*Auto-py-to-exe*](https://github.com/brentvollebregt/auto-py-to-exe) 兼容?)
|
||||
- [ ] [创建 `.spec` 文件](https://pyinstaller.org/en/stable/man/pyi-makespec.html)
|
||||
- [ ] 创建新的虚拟环境
|
||||
- [ ] 已识别系统解释器(或其他可用解释器)的前提下,提供创建新的 venv 虚拟环境功能
|
||||
@ -59,38 +65,40 @@
|
||||
## 界面
|
||||
|
||||
- [x] 实现跨平台功能
|
||||
- [x] 获取当前运行平台,保存至全局变量中
|
||||
- [x] 获取当前运行平台,保存至全局变量 `RUNTIME_INFO.platform` 中
|
||||
- [x] 定制各平台特有功能
|
||||
- [x] 使用 `qrc` 管理静态资源
|
||||
- [ ] 翻译与国际化
|
||||
- [ ] Qt 提供的界面文本自动翻译
|
||||
- [x] 翻译与国际化
|
||||
- [x] Qt 提供的界面文本自动翻译
|
||||
- [x] 自实现的不同语言下功能差异,如“打开PyInstaller文档”指向不同的链接等
|
||||
- [ ] 简洁视图/详细视图 切换
|
||||
|
||||
## 用户设置
|
||||
|
||||
- [ ] 在用户家目录中创建配置文件夹,用于保存用户设置
|
||||
- [ ] 在用户家目录中创建配置文件夹与配置文件(YAML 格式?),用于保存用户设置
|
||||
- [ ] 设置条目:
|
||||
- [ ] 界面语言
|
||||
- [ ] 是否使用 `--clean` `-y` 选项(默认自动使用)
|
||||
- [ ] 脚本导出格式(默认与当前平台对应,如 Windows 则为 PowerShell)
|
||||
|
||||
## 应用程序级
|
||||
|
||||
- [x] 解决相对引用与作为包运行问题
|
||||
- [ ] `logging` 日志记录
|
||||
- [ ] ~~将用户设置保存到文件中存储~~(暂无用户设置项)
|
||||
- [ ] (?) 将用户使用过的 Python 环境保存到缓存文件中存储,下次启动时自动加载
|
||||
- [ ] 缓存目录
|
||||
- [ ] (?) 将用户使用过的 Python 环境保存到缓存文件中存储,下次启动时自动加载
|
||||
- [ ] `logging` 日志记录 Py2exe-GUI 的运行过程
|
||||
|
||||
## 美化
|
||||
|
||||
- [ ] QSS 与美化
|
||||
- [ ] 动画效果
|
||||
- [ ] (?) 使用组件库
|
||||
|
||||
## 构建与分发
|
||||
|
||||
平台:
|
||||
|
||||
- [ ] Windows 发行版
|
||||
- [ ] 创建[版本资源文件](https://muzing.gitbook.io/pyinstaller-docs-zh-cn/usage#bu-huo-windows-ban-ben-shu-ju)
|
||||
- [ ] Linux 发行版
|
||||
|
||||
分发方式:
|
||||
@ -102,6 +110,12 @@
|
||||
|
||||
## 可选依赖
|
||||
|
||||
- [ ] 在 PyPI 上提供“完整版”的发行,包含以下所有可选依赖项
|
||||
- [ ] “普通版”也要有能力检测用户是否已经安装了某个/些可选依赖项并能协同工作
|
||||
- [ ] [Pillow](https://python-pillow.org/)
|
||||
- [ ] 更精确的图标文件格式识别
|
||||
- [ ] 自动将其他格式转换为平台对应的图标格式
|
||||
- [ ] 更精确可靠的图标文件格式识别(根据图片二进制内容判断,而不只是文件扩展名)
|
||||
- [ ] 在主窗口工具栏提供图像格式转换功能,将其他格式转换为平台对应的图标格式
|
||||
- [ ] [UPX](https://upx.github.io/)
|
||||
- [ ] [仅限 Windows 平台](https://muzing.gitbook.io/pyinstaller-docs-zh-cn/usage#shi-yong-upx)
|
||||
- [ ] 设法添加到运行时的环境变量 PATH 中
|
||||
- [ ] 或者,PyInstaller 命令中自动添加 `--upx-dir` 选项
|
||||
|
125
poetry.lock
generated
125
poetry.lock
generated
@ -358,6 +358,91 @@ files = [
|
||||
{file = "pefile-2023.2.7.tar.gz", hash = "sha256:82e6114004b3d6911c77c3953e3838654b04511b8b66e8583db70c65998017dc"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pillow"
|
||||
version = "10.2.0"
|
||||
description = "Python Imaging Library (Fork)"
|
||||
optional = true
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pillow-10.2.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:7823bdd049099efa16e4246bdf15e5a13dbb18a51b68fa06d6c1d4d8b99a796e"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:83b2021f2ade7d1ed556bc50a399127d7fb245e725aa0113ebd05cfe88aaf588"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fad5ff2f13d69b7e74ce5b4ecd12cc0ec530fcee76356cac6742785ff71c452"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da2b52b37dad6d9ec64e653637a096905b258d2fc2b984c41ae7d08b938a67e4"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:47c0995fc4e7f79b5cfcab1fc437ff2890b770440f7696a3ba065ee0fd496563"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:322bdf3c9b556e9ffb18f93462e5f749d3444ce081290352c6070d014c93feb2"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:51f1a1bffc50e2e9492e87d8e09a17c5eea8409cda8d3f277eb6edc82813c17c"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:69ffdd6120a4737710a9eee73e1d2e37db89b620f702754b8f6e62594471dee0"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-win32.whl", hash = "sha256:c6dafac9e0f2b3c78df97e79af707cdc5ef8e88208d686a4847bab8266870023"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:aebb6044806f2e16ecc07b2a2637ee1ef67a11840a66752751714a0d924adf72"},
|
||||
{file = "pillow-10.2.0-cp310-cp310-win_arm64.whl", hash = "sha256:7049e301399273a0136ff39b84c3678e314f2158f50f517bc50285fb5ec847ad"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:35bb52c37f256f662abdfa49d2dfa6ce5d93281d323a9af377a120e89a9eafb5"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9c23f307202661071d94b5e384e1e1dc7dfb972a28a2310e4ee16103e66ddb67"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:773efe0603db30c281521a7c0214cad7836c03b8ccff897beae9b47c0b657d61"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11fa2e5984b949b0dd6d7a94d967743d87c577ff0b83392f17cb3990d0d2fd6e"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:716d30ed977be8b37d3ef185fecb9e5a1d62d110dfbdcd1e2a122ab46fddb03f"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:a086c2af425c5f62a65e12fbf385f7c9fcb8f107d0849dba5839461a129cf311"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c8de2789052ed501dd829e9cae8d3dcce7acb4777ea4a479c14521c942d395b1"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:609448742444d9290fd687940ac0b57fb35e6fd92bdb65386e08e99af60bf757"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-win32.whl", hash = "sha256:823ef7a27cf86df6597fa0671066c1b596f69eba53efa3d1e1cb8b30f3533068"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:1da3b2703afd040cf65ec97efea81cfba59cdbed9c11d8efc5ab09df9509fc56"},
|
||||
{file = "pillow-10.2.0-cp311-cp311-win_arm64.whl", hash = "sha256:edca80cbfb2b68d7b56930b84a0e45ae1694aeba0541f798e908a49d66b837f1"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-macosx_10_10_x86_64.whl", hash = "sha256:1b5e1b74d1bd1b78bc3477528919414874748dd363e6272efd5abf7654e68bef"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0eae2073305f451d8ecacb5474997c08569fb4eb4ac231ffa4ad7d342fdc25ac"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7c2286c23cd350b80d2fc9d424fc797575fb16f854b831d16fd47ceec078f2c"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e23412b5c41e58cec602f1135c57dfcf15482013ce6e5f093a86db69646a5aa"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:52a50aa3fb3acb9cf7213573ef55d31d6eca37f5709c69e6858fe3bc04a5c2a2"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:127cee571038f252a552760076407f9cff79761c3d436a12af6000cd182a9d04"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:8d12251f02d69d8310b046e82572ed486685c38f02176bd08baf216746eb947f"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:54f1852cd531aa981bc0965b7d609f5f6cc8ce8c41b1139f6ed6b3c54ab82bfb"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-win32.whl", hash = "sha256:257d8788df5ca62c980314053197f4d46eefedf4e6175bc9412f14412ec4ea2f"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:154e939c5f0053a383de4fd3d3da48d9427a7e985f58af8e94d0b3c9fcfcf4f9"},
|
||||
{file = "pillow-10.2.0-cp312-cp312-win_arm64.whl", hash = "sha256:f379abd2f1e3dddb2b61bc67977a6b5a0a3f7485538bcc6f39ec76163891ee48"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:8373c6c251f7ef8bda6675dd6d2b3a0fcc31edf1201266b5cf608b62a37407f9"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:870ea1ada0899fd0b79643990809323b389d4d1d46c192f97342eeb6ee0b8483"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b4b6b1e20608493548b1f32bce8cca185bf0480983890403d3b8753e44077129"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3031709084b6e7852d00479fd1d310b07d0ba82765f973b543c8af5061cf990e"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:3ff074fc97dd4e80543a3e91f69d58889baf2002b6be64347ea8cf5533188213"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:cb4c38abeef13c61d6916f264d4845fab99d7b711be96c326b84df9e3e0ff62d"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b1b3020d90c2d8e1dae29cf3ce54f8094f7938460fb5ce8bc5c01450b01fbaf6"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:170aeb00224ab3dc54230c797f8404507240dd868cf52066f66a41b33169bdbe"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-win32.whl", hash = "sha256:c4225f5220f46b2fde568c74fca27ae9771536c2e29d7c04f4fb62c83275ac4e"},
|
||||
{file = "pillow-10.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:0689b5a8c5288bc0504d9fcee48f61a6a586b9b98514d7d29b840143d6734f39"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:b792a349405fbc0163190fde0dc7b3fef3c9268292586cf5645598b48e63dc67"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c570f24be1e468e3f0ce7ef56a89a60f0e05b30a3669a459e419c6eac2c35364"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8ecd059fdaf60c1963c58ceb8997b32e9dc1b911f5da5307aab614f1ce5c2fb"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c365fd1703040de1ec284b176d6af5abe21b427cb3a5ff68e0759e1e313a5e7e"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:70c61d4c475835a19b3a5aa42492409878bbca7438554a1f89d20d58a7c75c01"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:b6f491cdf80ae540738859d9766783e3b3c8e5bd37f5dfa0b76abdecc5081f13"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9d189550615b4948f45252d7f005e53c2040cea1af5b60d6f79491a6e147eef7"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:49d9ba1ed0ef3e061088cd1e7538a0759aab559e2e0a80a36f9fd9d8c0c21591"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-win32.whl", hash = "sha256:babf5acfede515f176833ed6028754cbcd0d206f7f614ea3447d67c33be12516"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:0304004f8067386b477d20a518b50f3fa658a28d44e4116970abfcd94fac34a8"},
|
||||
{file = "pillow-10.2.0-cp39-cp39-win_arm64.whl", hash = "sha256:0fb3e7fc88a14eacd303e90481ad983fd5b69c761e9e6ef94c983f91025da869"},
|
||||
{file = "pillow-10.2.0-pp310-pypy310_pp73-macosx_10_10_x86_64.whl", hash = "sha256:322209c642aabdd6207517e9739c704dc9f9db943015535783239022002f054a"},
|
||||
{file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3eedd52442c0a5ff4f887fab0c1c0bb164d8635b32c894bc1faf4c618dd89df2"},
|
||||
{file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cb28c753fd5eb3dd859b4ee95de66cc62af91bcff5db5f2571d32a520baf1f04"},
|
||||
{file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:33870dc4653c5017bf4c8873e5488d8f8d5f8935e2f1fb9a2208c47cdd66efd2"},
|
||||
{file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:3c31822339516fb3c82d03f30e22b1d038da87ef27b6a78c9549888f8ceda39a"},
|
||||
{file = "pillow-10.2.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a2b56ba36e05f973d450582fb015594aaa78834fefe8dfb8fcd79b93e64ba4c6"},
|
||||
{file = "pillow-10.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:d8e6aeb9201e655354b3ad049cb77d19813ad4ece0df1249d3c793de3774f8c7"},
|
||||
{file = "pillow-10.2.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:2247178effb34a77c11c0e8ac355c7a741ceca0a732b27bf11e747bbc950722f"},
|
||||
{file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15587643b9e5eb26c48e49a7b33659790d28f190fc514a322d55da2fb5c2950e"},
|
||||
{file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753cd8f2086b2b80180d9b3010dd4ed147efc167c90d3bf593fe2af21265e5a5"},
|
||||
{file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:7c8f97e8e7a9009bcacbe3766a36175056c12f9a44e6e6f2d5caad06dcfbf03b"},
|
||||
{file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:d1b35bcd6c5543b9cb547dee3150c93008f8dd0f1fef78fc0cd2b141c5baf58a"},
|
||||
{file = "pillow-10.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:fe4c15f6c9285dc54ce6553a3ce908ed37c8f3825b5a51a15c91442bb955b868"},
|
||||
{file = "pillow-10.2.0.tar.gz", hash = "sha256:e87f0b2c78157e12d7686b27d63c070fd65d994e8ddae6f328e0dcf4a0cd007e"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"]
|
||||
fpx = ["olefile"]
|
||||
mic = ["olefile"]
|
||||
tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"]
|
||||
typing = ["typing-extensions"]
|
||||
xmp = ["defusedxml"]
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "4.1.0"
|
||||
@ -442,41 +527,6 @@ importlib-metadata = {version = ">=4.6", markers = "python_version < \"3.10\""}
|
||||
packaging = ">=22.0"
|
||||
setuptools = ">=42.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "pyside6"
|
||||
version = "6.6.1"
|
||||
description = "Python bindings for the Qt cross-platform application and UI framework"
|
||||
optional = false
|
||||
python-versions = "<3.13,>=3.8"
|
||||
files = [
|
||||
{file = "PySide6-6.6.1-cp38-abi3-macosx_11_0_universal2.whl", hash = "sha256:3c348948fe3957b18164c9c7b8942fe065bdb39648b326f212bc114326679fa9"},
|
||||
{file = "PySide6-6.6.1-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:0a67587c088cb80e90d4ce3023b02466ea858c93a6dc9c4e062b13314e03d464"},
|
||||
{file = "PySide6-6.6.1-cp38-abi3-manylinux_2_31_aarch64.whl", hash = "sha256:ed3822150f0d7a06b68bf4ceebe287515b5e8309bb256e9b49ae405afd062b18"},
|
||||
{file = "PySide6-6.6.1-cp38-abi3-win_amd64.whl", hash = "sha256:3593d605175e83e6952cf3b428ecc9c146af97effb36de921ecf3da2752de082"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
PySide6-Addons = "6.6.1"
|
||||
PySide6-Essentials = "6.6.1"
|
||||
shiboken6 = "6.6.1"
|
||||
|
||||
[[package]]
|
||||
name = "pyside6-addons"
|
||||
version = "6.6.1"
|
||||
description = "Python bindings for the Qt cross-platform application and UI framework (Addons)"
|
||||
optional = false
|
||||
python-versions = "<3.13,>=3.8"
|
||||
files = [
|
||||
{file = "PySide6_Addons-6.6.1-cp38-abi3-macosx_11_0_universal2.whl", hash = "sha256:7cb7af1b050c40f7ac891b0e61c758c1923863173932f5b92dc47bdfb4158b42"},
|
||||
{file = "PySide6_Addons-6.6.1-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:a0982da4033319667f9df5ed6fa8eff300a88216aec103a1fff6751a172b19a0"},
|
||||
{file = "PySide6_Addons-6.6.1-cp38-abi3-manylinux_2_31_aarch64.whl", hash = "sha256:5a63a8a943724ce5acd2df72e5ab04982b6906963278cbabb216656b9a26ee18"},
|
||||
{file = "PySide6_Addons-6.6.1-cp38-abi3-win_amd64.whl", hash = "sha256:a223575c81e9a13173136c044c3447e25f6d656b462b4d71fc3c6bd9c935a709"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
PySide6-Essentials = "6.6.1"
|
||||
shiboken6 = "6.6.1"
|
||||
|
||||
[[package]]
|
||||
name = "pyside6-essentials"
|
||||
version = "6.6.1"
|
||||
@ -686,7 +736,10 @@ files = [
|
||||
docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"]
|
||||
testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"]
|
||||
|
||||
[extras]
|
||||
addons = ["Pillow"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">=3.8,<3.13"
|
||||
content-hash = "73b33938229a7a1fa491c925f43bcd0c9d65b1ba4c0518d145420e254eaf8a9a"
|
||||
content-hash = "9d916e9a86e4d370ec1d343ae2ada58e0a6822f41648dac6bef5d98079bb0f76"
|
||||
|
@ -29,10 +29,17 @@ py2exe-gui = 'py2exe_gui.__main__:main'
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8,<3.13"
|
||||
PySide6 = "^6.6.0"
|
||||
pyyaml = "^6.0.1"
|
||||
PySide6-Essentials = "^6.2.0"
|
||||
pyyaml = "^6.0.0"
|
||||
|
||||
Pillow = { version = "^10.0", optional = true }
|
||||
|
||||
[tool.poetry.extras]
|
||||
AddOns = ["Pillow"]
|
||||
|
||||
[tool.poetry.group.dev]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pre-commit = "^3.5.0"
|
||||
black = "^23.12.0"
|
||||
|
@ -1,5 +1,2 @@
|
||||
pyside6-addons==6.6.1 ; python_version >= "3.8" and python_version < "3.13"
|
||||
pyside6-essentials==6.6.1 ; python_version >= "3.8" and python_version < "3.13"
|
||||
pyside6==6.6.1 ; python_version >= "3.8" and python_version < "3.13"
|
||||
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "3.13"
|
||||
shiboken6==6.6.1 ; python_version >= "3.8" and python_version < "3.13"
|
||||
pyside6-essentials >= 6.2.0 ; python_version >= "3.8" and python_version < "3.13"
|
||||
pyyaml>=6.0.0 ; python_version >= "3.8" and python_version < "3.13"
|
||||
|
@ -15,6 +15,8 @@ __all__ = [
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import warnings
|
||||
from importlib import util as importlib_util
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
@ -29,17 +31,12 @@ class FilePathValidator:
|
||||
"""验证脚本路径是否有效
|
||||
|
||||
:param script_path: 脚本路径
|
||||
:return:脚本路径是否有效
|
||||
:return: 脚本路径是否有效
|
||||
"""
|
||||
|
||||
path = Path(script_path)
|
||||
|
||||
# 文件是否存在
|
||||
if not path.exists() or not path.is_file():
|
||||
return False
|
||||
|
||||
# 是否对文件有读取权限
|
||||
if not os.access(script_path, os.R_OK):
|
||||
if not (path.exists() and path.is_file() and os.access(script_path, os.R_OK)):
|
||||
return False
|
||||
|
||||
return True
|
||||
@ -49,19 +46,39 @@ class FilePathValidator:
|
||||
"""验证图标路径是否有效
|
||||
|
||||
:param icon_path: 图标路径
|
||||
:return: 图标是否有效
|
||||
"""
|
||||
|
||||
path = Path(icon_path)
|
||||
|
||||
if not path.exists() and path.is_file():
|
||||
if not (path.exists() and path.is_file() and os.access(icon_path, os.R_OK)):
|
||||
return False
|
||||
|
||||
# TODO 如果安装了可选依赖 Pillow,则进行更精确的判断和尝试转换图像格式
|
||||
if RUNTIME_INFO.platform == Platform.windows:
|
||||
return path.suffix == ".ico"
|
||||
elif RUNTIME_INFO.platform == Platform.macos:
|
||||
return path.suffix == ".icns"
|
||||
if importlib_util.find_spec("PIL") is not None:
|
||||
# 如果安装了可选依赖 Pillow,则进行更精确的判断
|
||||
from PIL import Image, UnidentifiedImageError
|
||||
|
||||
try:
|
||||
with Image.open(path) as img:
|
||||
img_format: str = img.format
|
||||
except UnidentifiedImageError:
|
||||
return False
|
||||
else:
|
||||
if img_format is None:
|
||||
return False
|
||||
elif RUNTIME_INFO.platform == Platform.windows:
|
||||
return img_format == "ICO"
|
||||
elif RUNTIME_INFO.platform == Platform.macos:
|
||||
return img_format == "ICNS"
|
||||
|
||||
else:
|
||||
# 若未安装 Pillow,则简单地用文件扩展名判断
|
||||
if RUNTIME_INFO.platform == Platform.windows:
|
||||
return path.suffix == ".ico"
|
||||
elif RUNTIME_INFO.platform == Platform.macos:
|
||||
return path.suffix == ".icns"
|
||||
|
||||
# 如果以上所有检查项均通过,默认返回 True
|
||||
return True
|
||||
|
||||
|
||||
@ -69,33 +86,30 @@ class InterpreterValidator:
|
||||
"""验证给定的可执行文件是否为有效的Python解释器"""
|
||||
|
||||
@classmethod
|
||||
def validate(cls, path: Union[str, Path, os.PathLike[str]]) -> bool:
|
||||
def validate(cls, itp_path: Union[str, Path, os.PathLike[str]]) -> bool:
|
||||
"""验证 `path` 是否指向有效的Python解释器
|
||||
|
||||
:param itp_path: 文件路径
|
||||
:return: 是否有效
|
||||
"""
|
||||
|
||||
itp_path = Path(path).absolute()
|
||||
path = Path(itp_path).absolute()
|
||||
|
||||
if not (
|
||||
itp_path.exists() # 该路径存在
|
||||
and itp_path.is_file() # 为文件
|
||||
and os.access(itp_path, os.X_OK) # 可执行权限
|
||||
):
|
||||
if not (path.exists() and path.is_file() and os.access(path, os.X_OK)):
|
||||
return False
|
||||
|
||||
# 尝试将该文件作为Python解释器运行
|
||||
subprocess_args = [str(path), "-c", "import sys"]
|
||||
try:
|
||||
# 尝试将该文件作为Python解释器运行
|
||||
subprocess_args = [str(itp_path), "-c", "import sys"]
|
||||
subprocess.run(args=subprocess_args, timeout=0.3, check=True)
|
||||
subprocess.run(args=subprocess_args, check=True)
|
||||
except subprocess.SubprocessError:
|
||||
return False
|
||||
except OSError as e:
|
||||
print(f"对 {path} 启动 Python 解释器有效性验证子进程失败:{e}")
|
||||
warnings.warn(
|
||||
f"Failed to start the Python interpreter validation subprocess for {path}: {e}",
|
||||
Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(InterpreterValidator.validate("/usr/bin/python"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user