Skip to content

Commit 21b30ce

Browse files
committed
Add UV-based build workflow matching local dependencies
1 parent d7a24b2 commit 21b30ce

3 files changed

Lines changed: 198 additions & 12 deletions

File tree

.github/workflows/build-uv.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Build with UV Dependencies
2+
3+
on:
4+
workflow_dispatch: # 手动触发
5+
6+
jobs:
7+
build-windows:
8+
runs-on: windows-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.8'
17+
18+
- name: Install UV
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install uv
22+
23+
- name: Install dependencies using UV (from pyproject.toml)
24+
run: |
25+
uv sync --frozen
26+
27+
- name: Verify installations
28+
run: |
29+
uv run python -c "import sys; print('Python version:', sys.version)"
30+
uv run python -c "import PyQt5; print('PyQt5 imported successfully')"
31+
uv run python -c "from PyQt5 import QtCore, QtGui, QtWidgets; print('PyQt5 modules OK')"
32+
uv run python -c "import numpy; print('NumPy version:', numpy.__version__)"
33+
uv run python -c "import PIL; print('Pillow version:', PIL.__version__)"
34+
35+
- name: Test compile main_qt5.py
36+
run: |
37+
cd video_clips
38+
uv run python -m py_compile main_qt5.py
39+
echo "main_qt5.py syntax OK"
40+
41+
- name: Build with PyInstaller using UV environment
42+
run: |
43+
cd video_clips
44+
uv run python -m PyInstaller --clean --noconfirm --onefile --name "VideoClipsApp" --hidden-import "PyQt5.QtCore" --hidden-import "PyQt5.QtGui" --hidden-import "PyQt5.QtWidgets" --hidden-import "PyQt5.sip" --hidden-import "numpy" --hidden-import "PIL.Image" --collect-submodules "PyQt5" main_qt5.py
45+
46+
- name: Verify build output
47+
run: |
48+
cd video_clips
49+
dir dist
50+
if exist dist\VideoClipsApp.exe (echo "SUCCESS: VideoClipsApp.exe created" && dir dist\VideoClipsApp.exe) else (echo "ERROR: VideoClipsApp.exe not found")
51+
52+
- name: Create Release Package
53+
run: |
54+
cd video_clips
55+
mkdir release
56+
copy dist\VideoClipsApp.exe release\
57+
echo @echo off > release\run_app.bat
58+
echo echo Starting VideoClipsApp... >> release\run_app.bat
59+
echo VideoClipsApp.exe >> release\run_app.bat
60+
echo pause >> release\run_app.bat
61+
echo UV Dependencies Build - VideoClipsApp Windows Executable > release\README.txt
62+
echo Double-click VideoClipsApp.exe to run the application >> release\README.txt
63+
64+
- name: Upload Release Artifact
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: VideoClipsApp-Windows-UV
68+
path: video_clips/release/
69+
retention-days: 30
70+
71+
build-linux:
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v4
79+
with:
80+
python-version: '3.8'
81+
82+
- name: Install system dependencies
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install -y python3-pyqt5
86+
87+
- name: Install UV
88+
run: |
89+
python -m pip install --upgrade pip
90+
pip install uv
91+
92+
- name: Install dependencies using UV (from pyproject.toml)
93+
run: |
94+
uv sync --frozen
95+
96+
- name: Build with PyInstaller using UV environment
97+
run: |
98+
cd video_clips
99+
uv run python -m PyInstaller --clean --noconfirm --onefile --name "VideoClipsApp" --hidden-import "PyQt5.QtCore" --hidden-import "PyQt5.QtGui" --hidden-import "PyQt5.QtWidgets" --hidden-import "PyQt5.sip" --hidden-import "numpy" --hidden-import "PIL.Image" --collect-submodules "PyQt5" main_qt5.py
100+
101+
- name: Create Release Package
102+
run: |
103+
cd video_clips
104+
mkdir -p release
105+
cp dist/VideoClipsApp release/
106+
cat > release/run_app.sh << 'EOF'
107+
#!/bin/bash
108+
cd "$(dirname "$0")"
109+
echo "Starting VideoClipsApp..."
110+
./VideoClipsApp
111+
EOF
112+
chmod +x release/run_app.sh
113+
echo "UV Dependencies Build - VideoClipsApp Linux Executable" > release/README.txt
114+
echo "Run ./VideoClipsApp or use ./run_app.sh" >> release/README.txt
115+
116+
- name: Upload Release Artifact
117+
uses: actions/upload-artifact@v3
118+
with:
119+
name: VideoClipsApp-Linux-UV
120+
path: video_clips/release/
121+
retention-days: 30

.github/workflows/build.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ jobs:
1515
with:
1616
python-version: '3.8'
1717

18-
- name: Install dependencies with specific versions
18+
- name: Install UV dependencies (matching pyproject.toml)
1919
run: |
2020
python -m pip install --upgrade pip
21-
pip install PyQt5==5.15.10
22-
pip install PyQt5-Qt5==5.15.2
23-
pip install PyQt5-sip==12.13.0
24-
pip install numpy==1.21.6
25-
pip install Pillow==9.5.0
26-
pip install pyinstaller==6.10.0
21+
pip install PyQt5>=5.15
22+
pip install numpy==1.24.3
23+
pip install Pillow==10.0.0
24+
pip install matplotlib==3.7.2
25+
pip install tqdm==4.66.1
26+
pip install pyinstaller>=6.16.0
2727
2828
- name: Verify installations
2929
run: |
@@ -89,13 +89,15 @@ jobs:
8989
sudo apt-get update
9090
sudo apt-get install -y python3-pyqt5
9191
92-
- name: Install Python dependencies
92+
- name: Install UV dependencies (matching pyproject.toml)
9393
run: |
9494
python -m pip install --upgrade pip
95-
pip install PyQt5==5.15.10
96-
pip install numpy==1.21.6
97-
pip install Pillow==9.5.0
98-
pip install pyinstaller==6.10.0
95+
pip install PyQt5>=5.15
96+
pip install numpy==1.24.3
97+
pip install Pillow==10.0.0
98+
pip install matplotlib==3.7.2
99+
pip install tqdm==4.66.1
100+
pip install pyinstaller>=6.16.0
99101
100102
- name: Build with PyInstaller
101103
run: |

UV_BUILD_SOLUTION.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# UV 依赖构建方案
2+
3+
## 🎯 问题解决
4+
5+
您使用 UV 管理依赖确实很重要!UV 锁定了具体的版本,这影响了构建的成功率。
6+
7+
### 📋 您的 UV 环境依赖版本:
8+
```toml
9+
PyQt5 >= 5.15
10+
numpy == 1.24.3
11+
Pillow == 10.0.0
12+
matplotlib == 3.7.2
13+
tqdm == 4.66.1
14+
pyinstaller >= 6.16.0
15+
```
16+
17+
这些版本与我之前使用的版本不同,可能导致兼容性问题。
18+
19+
## 🚀 新的构建方案
20+
21+
### 方案一:使用 UV 构建 (推荐)
22+
创建了 `build-uv.yml` - 直接使用 UV 和您的 `pyproject.toml`
23+
24+
**优势:**
25+
- ✅ 完全匹配您的本地环境
26+
- ✅ 使用锁定的依赖版本
27+
- ✅ 避免版本冲突
28+
29+
**使用步骤:**
30+
1. 提交代码
31+
2. 在 Actions 页面运行 "Build with UV Dependencies"
32+
33+
### 方案二:更新现有构建
34+
已更新 `build.yml` 使用您的具体版本:
35+
- numpy==1.24.3 (而不是 1.21.6)
36+
- Pillow==10.0.0 (而不是 9.5.0)
37+
- pyinstaller>=6.16.0 (匹配您的版本)
38+
39+
## 🔧 关键差异
40+
41+
### 之前的构建失败可能因为:
42+
1. **NumPy 版本冲突**:1.21.6 vs 1.24.3
43+
2. **Pillow 版本冲突**:9.5.0 vs 10.0.0
44+
3. **PyInstaller 版本**:6.10.0 vs 6.16.0+
45+
46+
### UV 的优势:
47+
- 锁定依赖,避免版本飘移
48+
- 跨平台一致性
49+
- 更快的安装速度
50+
51+
## 📝 下一步
52+
53+
```bash
54+
git add .
55+
git commit -m "Add UV-based build workflow matching local dependencies"
56+
git push origin main
57+
```
58+
59+
然后运行 **"Build with UV Dependencies"** workflow。
60+
61+
如果 UV 方案也有问题,我们还有兼容性更新的标准 pip 方案作为备选。
62+
63+
UV 确实很重要 - 让我们用您的真实环境来构建!

0 commit comments

Comments
 (0)