Skip to content

Commit 46e7a9e

Browse files
authored
Merge pull request #41 from chenjintang-shrimp/migrate-pyside6
迁移到pyside6,极大提升性能,更新打包脚本
2 parents a59f568 + c563417 commit 46e7a9e

91 files changed

Lines changed: 3685 additions & 1756 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-nuitka.yml

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
name: 构建 (Nuitka)
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: build-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
builder_matrix:
14+
# 仅在push或pull_request事件包含'进行打包'时执行,workflow_dispatch无条件执行
15+
if: |
16+
github.event_name == 'workflow_dispatch' ||
17+
contains(github.event.head_commit.message, 'nuitka进行打包') ||
18+
(github.event_name == 'pull_request' && contains(github.event.pull_request.title, '进行打包'))
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- os: windows-2022
24+
arch: x64
25+
pack_mode: dir
26+
- os: windows-2022
27+
arch: x86
28+
pack_mode: dir
29+
30+
runs-on: ${{ matrix.os }}
31+
steps:
32+
- name: 检出仓库
33+
uses: actions/checkout@v4.2.2
34+
- name: 安装 Python
35+
uses: actions/setup-python@v5.3.0
36+
with:
37+
python-version: "3.8.10"
38+
architecture: ${{ matrix.arch }}
39+
- name: 安装 uv
40+
uses: astral-sh/setup-uv@v4
41+
42+
- name: 初始化 zip 文件夹
43+
run: mkdir zip
44+
45+
- name: 更新 version_info.txt
46+
if: startsWith(github.ref_name, 'v')
47+
run: |
48+
python update_version.py
49+
env:
50+
VERSION: ${{ github.ref_name }}
51+
52+
- name: 运行 Windows 构建 (PyInstaller)
53+
if: ${{ matrix.os == 'windows-2022' }}
54+
run: |
55+
echo "开始 Windows 构建流程..."
56+
# 直接运行打包脚本build_pyinstaller.py
57+
uv sync
58+
uv run build_pyinstaller.py
59+
60+
- name: 打包操作
61+
if: ${{ matrix.os == 'windows-2022'}}
62+
run: |
63+
echo "开始打包操作..."
64+
65+
# 创建zip_dist/SecRandom目录
66+
mkdir -p zip_dist/SecRandom
67+
68+
# 复制dist/SecRandom目录下的所有文件到zip_dist/SecRandom目录下
69+
Copy-Item -Recurse -Force dist/SecRandom/* zip_dist/SecRandom/
70+
71+
# 创建app目录
72+
mkdir -p zip_dist/SecRandom/app
73+
74+
# 复制app/resources文件夹到zip_dist/SecRandom目录下
75+
Copy-Item -Recurse -Force app/resources zip_dist/SecRandom/app
76+
77+
# 复制 LICENSE 文件到zip_dist/SecRandom目录下
78+
Copy-Item LICENSE zip_dist/SecRandom/
79+
80+
# 使用 zip 压缩文件
81+
mkdir zip -Force
82+
$outputZip = "zip/SecRandom-Windows-${{ github.ref_name }}-${{ matrix.arch }}-dir.zip"
83+
Compress-Archive -Path zip_dist/SecRandom/* -DestinationPath $outputZip -Force
84+
echo "目录模式打包完成: $outputZip"
85+
86+
- name: 上传应用程序
87+
if: ${{ github.event_name != 'pull_request' }}
88+
uses: actions/upload-artifact@v4.4.2
89+
with:
90+
name: windows-2022-${{ matrix.arch }}-${{ matrix.pack_mode }}
91+
path: ./zip
92+
93+
release:
94+
needs: [builder_matrix]
95+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: write
99+
steps:
100+
- name: Check out repository
101+
uses: actions/checkout@v3
102+
with:
103+
fetch-depth: 0
104+
105+
- name: 设置 git-cliff
106+
uses: kenji-miyake/setup-git-cliff@v1
107+
108+
- name: 生成 changelog
109+
id: generate-changelog
110+
run: |
111+
git cliff
112+
113+
- name: 准备发布
114+
run: |
115+
echo "准备发布目录..."
116+
mkdir -p release
117+
mkdir -p artifacts
118+
119+
- name: 下载 artifacts
120+
uses: actions/download-artifact@v4
121+
with:
122+
path: artifacts
123+
run-id: ${{ github.run_id }}
124+
125+
- name: 准备 artifacts
126+
run: |
127+
echo "整理构建产物..."
128+
# Windows 构建产物
129+
mv artifacts/windows-2022-x64-dir/* release/ 2>/dev/null || echo "未找到 Windows x64-dir 构建产物"
130+
mv artifacts/windows-2022-x86-dir/* release/ 2>/dev/null || echo "未找到 Windows x86-dir 构建产物"
131+
echo "构建产物整理完成"
132+
ls -la release/
133+
134+
- name: 计算 SHA256 值
135+
run: |
136+
echo "开始计算SHA256校验值..."
137+
cd release
138+
echo "" > SHA256SUMS.txt
139+
for file in *; do
140+
if [ -f "$file" ]; then
141+
echo "计算 $file 的SHA256值..."
142+
sha256sum "$file" >> SHA256SUMS.txt
143+
fi
144+
done
145+
echo "SHA256校验值计算完成:"
146+
cat SHA256SUMS.txt
147+
148+
- name: 验证 SHA256SUMS.txt 文件
149+
run: |
150+
echo "验证SHA256SUMS.txt文件..."
151+
cd release
152+
if [ ! -f "SHA256SUMS.txt" ]; then
153+
echo "错误:在release目录中未找到SHA256SUMS.txt文件"
154+
exit 1
155+
fi
156+
if [ ! -s "SHA256SUMS.txt" ]; then
157+
echo "错误:SHA256SUMS.txt文件为空"
158+
exit 1
159+
fi
160+
echo "SHA256SUMS.txt文件验证通过"
161+
cd ..
162+
163+
- name: 生成 需发布 的表格信息
164+
run: |
165+
cd release
166+
echo "" >> ../CHANGELOG.md
167+
echo "Full Changelog: [v1.3.0.5...${{ github.ref_name }}](https://github.com/SECTL/SecRandom/compare/v1.3.0.5...${{ github.ref_name }})" >> ../CHANGELOG.md
168+
echo "" >> ../CHANGELOG.md
169+
echo "**国内 下载链接**" >> ../CHANGELOG.md
170+
echo "| 平台/打包方式 | 支持架构 | 完整版 |" >> ../CHANGELOG.md
171+
echo "| --- | --- | --- |" >> ../CHANGELOG.md
172+
echo "| Windows | x64, x86 | [下载](https://www.123684.com/s/9529jv-U4Fxh) |" >> ../CHANGELOG.md
173+
echo "" >> ../CHANGELOG.md
174+
echo "**Github 镜像 下载链接**" >> ../CHANGELOG.md
175+
echo "| 镜像源 | 平台/打包方式 | 支持架构 | 完整版 |" >> ../CHANGELOG.md
176+
echo "| --- | --- | --- | --- |" >> ../CHANGELOG.md
177+
echo "| ghfast.top | Windows 目录模式 | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
178+
echo "| ghfast.top | Windows 目录模式 | x86 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
179+
echo "| gh-proxy.com | Windows 目录模式 | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
180+
echo "| gh-proxy.com | Windows 目录模式 | x86 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
181+
echo "" >> ../CHANGELOG.md
182+
echo "**SHA256 校验值-请核对下载的文件的SHA256值是否正确**" >> ../CHANGELOG.md
183+
echo "| 文件名 | SHA256 值 |" >> ../CHANGELOG.md
184+
echo "| --- | --- |" >> ../CHANGELOG.md
185+
while read -r line; do
186+
hash=$(echo "$line" | awk '{print $1}')
187+
file=$(echo "$line" | awk '{print $2}')
188+
echo "| $file | $hash |" >> ../CHANGELOG.md
189+
done < SHA256SUMS.txt
190+
rm SHA256SUMS.txt
191+
cd ..
192+
193+
- name: 确定发布类型
194+
id: release-type
195+
run: |
196+
if [[ "${{ github.ref }}" == *"beta"* || "${{ github.ref }}" == *"alpha"* ]]; then
197+
echo "is_beta=true" >> $GITHUB_ENV
198+
else
199+
echo "is_beta=false" >> $GITHUB_ENV
200+
fi
201+
202+
- name: 发布
203+
uses: softprops/action-gh-release@v2
204+
with:
205+
token: ${{ secrets.Releases_BOT }}
206+
files: release/*
207+
body_path: CHANGELOG.md
208+
draft: false
209+
prerelease: ${{ env.is_beta == 'true' }}
210+
tag_name: ${{ github.ref_name }}
211+
name: SecRandom 新版本 - ${{ github.ref_name }}
212+
fail_on_unmatched_files: true
213+
env:
214+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build.yml

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 构建
1+
name: 构建 (PyInstaller)
22

33
on:
44
push:
@@ -49,52 +49,13 @@ jobs:
4949
env:
5050
VERSION: ${{ github.ref_name }}
5151

52-
- name: 运行 Windows 构建
52+
- name: 运行 Windows 构建 (PyInstaller)
5353
if: ${{ matrix.os == 'windows-2022' }}
5454
run: |
5555
echo "开始 Windows 构建流程..."
56-
# 创建虚拟环境
57-
echo "创建虚拟环境..."
58-
uv venv
59-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
60-
61-
# 激活虚拟环境
62-
echo "激活虚拟环境..."
63-
.venv/Scripts/activate
64-
65-
# 安装依赖
66-
echo "安装项目依赖..."
56+
# 直接运行打包脚本build_pyinstaller.py
6757
uv sync
68-
69-
# 安装 pyinstaller
70-
echo "安装 PyInstaller..."
71-
uv pip install pyinstaller
72-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
73-
74-
# 清理之前的构建文件
75-
echo "清理之前的构建文件..."
76-
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
77-
Remove-Item -Recurse -Force build -ErrorAction SilentlyContinue
78-
Remove-Item -Recurse -Force zip_dist -ErrorAction SilentlyContinue
79-
echo "构建环境准备完成"
80-
# 根据打包模式选择不同的PyInstaller参数
81-
if ('${{ matrix.pack_mode }}' -eq 'dir') {
82-
# 目录模式打包
83-
echo "开始目录模式打包..."
84-
pyinstaller main.py `
85-
-w `
86-
-D `
87-
-i ./resources/secrandom-icon-paper.ico `
88-
-n SecRandom `
89-
--add-data ./app/resources:app/resources `
90-
--add-data LICENSE:. `
91-
--version-file=version_info.txt
92-
if ($LASTEXITCODE -ne 0) {
93-
echo "目录模式打包失败"
94-
exit $LASTEXITCODE
95-
}
96-
echo "目录模式打包完成"
97-
}
58+
uv run build_pyinstaller.py
9859
9960
- name: 打包操作
10061
if: ${{ matrix.os == 'windows-2022'}}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ MANIFEST
3030
# Usually these files are written by a python script from a template
3131
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3232
*.manifest
33-
*.spec
3433

3534
# Installer logs
3635
pip-log.txt

Secrandom.spec

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""PyInstaller spec leveraging shared packaging utilities."""
2+
3+
from PyInstaller.utils.hooks import collect_data_files
4+
5+
from packaging_utils import (
6+
ADDITIONAL_HIDDEN_IMPORTS,
7+
collect_data_includes,
8+
collect_language_modules,
9+
collect_view_modules,
10+
normalize_hidden_imports,
11+
)
12+
13+
block_cipher = None
14+
15+
base_datas = [(str(item.source), item.target) for item in collect_data_includes()]
16+
17+
try:
18+
qfluentwidgets_datas = collect_data_files("qfluentwidgets")
19+
except Exception as exc:
20+
print(f"Warning: unable to collect qfluentwidgets resources: {exc}")
21+
qfluentwidgets_datas = []
22+
23+
all_datas = base_datas + qfluentwidgets_datas
24+
25+
language_hiddenimports = collect_language_modules()
26+
view_hiddenimports = collect_view_modules()
27+
28+
all_hiddenimports = normalize_hidden_imports(
29+
language_hiddenimports + view_hiddenimports + ADDITIONAL_HIDDEN_IMPORTS
30+
)
31+
32+
a = Analysis(
33+
["main.py"],
34+
pathex=[],
35+
binaries=[],
36+
datas=all_datas,
37+
hiddenimports=all_hiddenimports,
38+
hookspath=[],
39+
hooksconfig={},
40+
runtime_hooks=[],
41+
excludes=[],
42+
win_no_prefer_redirects=False,
43+
win_private_assemblies=False,
44+
cipher=block_cipher,
45+
noarchive=False,
46+
)
47+
48+
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
49+
50+
exe = EXE(
51+
pyz,
52+
a.scripts,
53+
a.binaries,
54+
a.zipfiles,
55+
a.datas,
56+
[],
57+
name="SecRandom",
58+
debug=False,
59+
bootloader_ignore_signals=False,
60+
strip=False,
61+
upx=True,
62+
upx_exclude=[],
63+
runtime_tmpdir=None,
64+
console=False,
65+
disable_windowed_traceback=False,
66+
argv_emulation=False,
67+
target_arch=None,
68+
codesign_identity=None,
69+
entitlements_file=None,
70+
)

app/Language/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Language package

app/Language/modules/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Language modules package
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
# 剩余名单页面语言配置
22
remaining_list = {
33
"ZH_CN": {
4-
"title": {
5-
"name": "未抽取学生名单",
6-
"description": "剩余名单页面标题"
7-
},
4+
"title": {"name": "未抽取学生名单", "description": "剩余名单页面标题"},
85
"title_with_class": {
96
"name": "{class_name} - 未抽取学生名单",
10-
"description": "带班级名称的标题"
11-
},
12-
"count_label": {
13-
"name": "剩余人数:{count}",
14-
"description": "剩余人数标签文本"
7+
"description": "带班级名称的标题",
158
},
9+
"count_label": {"name": "剩余人数:{count}", "description": "剩余人数标签文本"},
1610
"no_students": {
1711
"name": "暂无未抽取的学生",
18-
"description": "没有剩余学生时的提示文本"
12+
"description": "没有剩余学生时的提示文本",
1913
},
2014
"student_info": {
2115
"name": "学号: {id}\n性别: {gender}\n小组: {group}",
22-
"description": "学生卡片信息格式"
23-
}
16+
"description": "学生卡片信息格式",
17+
},
2418
}
25-
}
19+
}

0 commit comments

Comments
 (0)