Repository navigation
174 lines (153 loc) · 5.62 KB
/
Copy pathpython-app.yml
File metadata and controls
174 lines (153 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# CI: Windows/Linux 双端测试
name: CI / Build (Nuitka)
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- name: Windows+GCC
os: windows-latest
python-version: '3.12'
nuitka-compiler-flag: '--mingw64'
needs-vcvars: false
- name: Windows+VC
os: windows-latest
python-version: '3.13'
nuitka-compiler-flag: ''
needs-vcvars: true
- name: Ubuntu+gcc
os: ubuntu-24.04
python-version: '3.13'
nuitka-compiler-flag: ''
needs-vcvars: false
runs-on: ${{ matrix.os }}
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
cache: pip
# Linux: gcc + zlib1g-dev
- name: apt deps
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y build-essential zlib1g-dev
# Windows 3.12: winget 装 MSYS2 MinGW64, 加 PATH
- name: 安装 MinGW64
if: runner.os == 'Windows' && matrix.python-version == '3.12'
shell: pwsh
run: |
winget install -e --id MSYS2.MSYS2 --accept-package-agreements --accept-source-agreements
"C:\msys64\mingw64\bin" | Out-File "$env:GITHUB_PATH" -Append -Encoding utf8
gcc --version
- name: 安装依赖
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: flake8
run: |
pip install flake8
flake8 --max-line-length=100 --extend-ignore=E501,W503,E265,E303,E305,E127,E741 . || true
- name: 程序冒烟测试
run: |
python -c "
import py_compile, glob, sys
for f in glob.glob('modules/*.py') + ['main.py']:
py_compile.compile(f, doraise=True)
sys.path.insert(0, '.')
from modules import config, deps, builder
print('OK')
"
# Windows+VC
- name: MSVC nuitka构建
if: runner.os == 'Windows' && matrix.needs-vcvars
shell: pwsh
run: |
# 注入 MSVC 环境
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installPath = & $vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $installPath) { throw "MSVC not found" }
Write-Host "VS: $installPath"
$vsdev = Join-Path $installPath "Common7\Tools\VsDevCmd.bat"
$tmp = [System.IO.Path]::GetTempFileName()
cmd /c "`"$vsdev`" -arch=x64 -host_arch=x64 && set > `"$tmp`""
Get-Content $tmp | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { Set-Item -Path "Env:$($matches[1])" -Value $matches[2] }
}
Remove-Item $tmp -Force
cl
# 构建 — 普通数组 + splat (@), 空值已经在矩阵里不存在
$flags = @(
'--standalone', '--onefile', '--enable-plugin=pyside6',
'--assume-yes-for-downloads', '--jobs=4',
'--windows-console-mode=disable', '--windows-icon-from-ico=a.ico',
'--include-data-files=a.ico=a.ico',
'--output-filename=NuitkaGUI.exe', '--output-dir=dist', 'main.py'
)
Write-Host "nuitka $($flags -join ' ')"
python -m nuitka @flags
# 其他 (Ubuntu+gcc/Windows+GCC)
- name: nuitka build
if: matrix.needs-vcvars == false
shell: bash
run: |
IS_LINUX="${{ runner.os }}"
CC_FLAG="${{ matrix.nuitka-compiler-flag }}"
FLAGS=(
--standalone --onefile --enable-plugin=pyside6
--assume-yes-for-downloads --jobs=4
)
# 编译器 flag — 仅非空时追加
[ -n "$CC_FLAG" ] && FLAGS+=("$CC_FLAG")
# Windows 专属
if [ "$IS_LINUX" != "Linux" ]; then
FLAGS+=(--windows-console-mode=disable --windows-icon-from-ico=a.ico --include-data-files=a.ico=a.ico)
EXE="NuitkaGUI.exe"
else
EXE="NuitkaGUI"
fi
FLAGS+=(--output-filename="$EXE" --output-dir=dist main.py)
echo "nuitka ${FLAGS[*]}"
python -m nuitka "${FLAGS[@]}"
- name: 验证
shell: bash
run: |
IS_LINUX="${{ runner.os }}"
if [ "$IS_LINUX" = "Linux" ]; then
test -f dist/NuitkaGUI || { echo "FAIL: no binary"; exit 1; }
file dist/NuitkaGUI | grep -q ELF && echo "ELF OK"
ldd dist/NuitkaGUI | grep "not found" || true
else
test -f dist/NuitkaGUI.exe || { echo "FAIL: no exe"; exit 1; }
ls -lh dist/NuitkaGUI.exe
fi
# 启动测试
- name: 冒烟测试启动
if: runner.os == 'Linux'
run: |
sudo apt-get install -y xvfb
timeout 6 xvfb-run -a ./dist/NuitkaGUI || true
- name: 冒烟测试(Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$p = Start-Process dist\NuitkaGUI.exe -PassThru -WindowStyle Hidden
Start-Sleep 5
if (-not $p.HasExited) { Stop-Process -Id $p.Id -Force; Write-Host "OK 启动后 3s 存活" }
- uses: actions/upload-artifact@v7
with:
name: NuitkaGUI-${{ matrix.name }}
path: dist
if-no-files-found: error
retention-days: 7