Skip to content

Commit 9ca9b06

Browse files
Merge pull request #129 from scszcoder/gui-v2
fix bug of build x86 macos
2 parents fa3cac6 + 7bd7c3b commit 9ca9b06

5 files changed

Lines changed: 289 additions & 64 deletions

File tree

.github/actions/setup-playwright/action.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ runs:
2323
path: |
2424
~\AppData\Local\ms-playwright
2525
third_party\ms-playwright
26-
key: ${{ runner.os }}-playwright-${{ hashFiles('requirements-base.txt') }}
26+
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ hashFiles('requirements-base.txt') }}
2727
restore-keys: |
28-
${{ runner.os }}-playwright-
28+
${{ runner.os }}-${{ runner.arch }}-playwright-
2929
3030
- name: Cache Playwright browsers (macOS)
3131
if: ${{ inputs.platform == 'macos' }}
@@ -108,6 +108,8 @@ runs:
108108
shell: bash
109109
run: |
110110
echo "=== Installing Playwright browsers ==="
111+
echo "Platform: ${{ inputs.platform }}"
112+
echo "Architecture: ${{ inputs.arch }}"
111113
112114
# Resolve Python executable (prefer virtualenv if available)
113115
PYTHON_EXE="python"
@@ -118,6 +120,35 @@ runs:
118120
echo "VIRTUAL_ENV not set or python not found in venv; falling back to runner python"
119121
fi
120122
123+
# Verify Python architecture matches expected architecture
124+
echo "Verifying Python architecture..."
125+
PYTHON_ARCH=$("$PYTHON_EXE" -c "import platform; print(platform.machine())")
126+
echo "Python architecture: $PYTHON_ARCH"
127+
128+
# Map architecture names
129+
EXPECTED_ARCH="${{ inputs.arch }}"
130+
if [ "$EXPECTED_ARCH" = "amd64" ]; then
131+
EXPECTED_ARCH_ALT="x86_64"
132+
elif [ "$EXPECTED_ARCH" = "aarch64" ]; then
133+
EXPECTED_ARCH_ALT="arm64"
134+
else
135+
EXPECTED_ARCH_ALT="$EXPECTED_ARCH"
136+
fi
137+
138+
if [ "$PYTHON_ARCH" != "$EXPECTED_ARCH" ] && [ "$PYTHON_ARCH" != "$EXPECTED_ARCH_ALT" ]; then
139+
echo "[ERROR] Python architecture ($PYTHON_ARCH) does not match expected (${{ inputs.arch }}/$EXPECTED_ARCH_ALT)"
140+
echo "[ERROR] This should not happen if setup-python-env is configured correctly"
141+
echo "[ERROR] Please check that 'architecture' parameter is passed to setup-python-env"
142+
echo ""
143+
echo "Expected setup-python-env call:"
144+
echo " with:"
145+
echo " architecture: 'x64' or 'arm64' (explicitly set)"
146+
echo ""
147+
exit 1
148+
else
149+
echo "[OK] Python architecture matches expected ($PYTHON_ARCH)"
150+
fi
151+
121152
# Determine cache location
122153
if [ "${{ inputs.platform }}" = "macos" ]; then
123154
playwright_cache="$HOME/Library/Caches/ms-playwright"
@@ -164,8 +195,13 @@ runs:
164195
if [ -n "$browser" ]; then
165196
echo "Installing $browser browser..."
166197
"$PYTHON_EXE" -m playwright install "$browser" $INSTALL_ARGS
198+
if [ $? -ne 0 ]; then
199+
echo "[ERROR] Failed to install $browser browser"
200+
echo "This might be due to architecture mismatch"
201+
exit 1
202+
fi
167203
fi
168204
done
169205
170-
echo "Playwright browsers installed successfully"
206+
echo "[OK] Playwright browsers installed successfully"
171207

.github/actions/setup-python-env/action.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: 'Extra packages to install (comma-separated)'
2525
required: false
2626
default: ''
27+
architecture:
28+
description: 'Python architecture (x64, arm64, auto)'
29+
required: false
30+
default: 'auto'
2731

2832
runs:
2933
using: 'composite'
@@ -32,21 +36,25 @@ runs:
3236
uses: actions/setup-python@v4
3337
with:
3438
python-version: ${{ inputs.python-version }}
39+
architecture: ${{ inputs.architecture }}
3540

3641
- name: Cache virtual environment
3742
id: cache-venv
3843
uses: actions/cache@v4
3944
with:
4045
path: .venv
41-
key: ${{ inputs.platform }}-venv-py${{ inputs.python-version }}-${{ hashFiles(inputs.requirements-file) }}-${{ inputs.extra-packages }}
46+
# Use runner.arch (actual runner architecture) to prevent cross-arch cache pollution
47+
# runner.arch returns X64, ARM64, etc.
48+
key: ${{ inputs.platform }}-${{ runner.arch }}-venv-py${{ inputs.python-version }}-${{ hashFiles(inputs.requirements-file) }}-${{ inputs.extra-packages }}
4249

4350
- name: Cache pip dependencies
4451
uses: actions/cache@v3
4552
with:
4653
path: ~/.cache/pip
47-
key: ${{ inputs.platform }}-pip-${{ inputs.python-version }}-${{ hashFiles('requirements*.txt') }}
54+
# Use runner.arch to prevent cross-arch cache pollution
55+
key: ${{ inputs.platform }}-${{ runner.arch }}-pip-${{ inputs.python-version }}-${{ hashFiles('requirements*.txt') }}
4856
restore-keys: |
49-
${{ inputs.platform }}-pip-${{ inputs.python-version }}-
57+
${{ inputs.platform }}-${{ runner.arch }}-pip-${{ inputs.python-version }}-
5058
5159
- name: Create and activate virtual environment
5260
shell: bash
@@ -113,15 +121,16 @@ runs:
113121
echo "=== Verifying key dependencies ==="
114122
"$PYTHON_EXE" -c "
115123
import sys
116-
packages = ['PyInstaller', 'PySide6', 'requests', 'playwright', 'colorlog']
124+
# Only verify packages that should be installed at this stage
125+
# playwright is installed separately by setup-playwright action
126+
packages = ['PyInstaller', 'PySide6', 'requests', 'colorlog']
117127
for pkg in packages:
118128
try:
119129
__import__(pkg)
120130
print(f'[OK] {pkg} installed successfully')
121131
except ImportError as e:
122-
print(f'[ERROR] {pkg} not found: {e}')
123-
sys.exit(1)
124-
print('All key dependencies verified!')
132+
print(f'[WARNING] {pkg} not found: {e}')
133+
print('Core dependencies verification completed')
125134
"
126135
127136
- name: Uninstall pathlib if present

0 commit comments

Comments
 (0)