fix(build): update macOS build process to install x86_64 libyaml and improve handling of arch-only Mach-O binaries

This commit is contained in:
Ivan
2026-04-30 12:58:22 -05:00
parent d92c2efc22
commit da60483484
2 changed files with 28 additions and 3 deletions
+18
View File
@@ -362,11 +362,29 @@ jobs:
if: matrix.label == 'macos'
run: echo "PYTHON_CMD_X64=${{ steps.python_x64.outputs.python-path }}" >> "$GITHUB_ENV"
- name: Install x86_64 libyaml for universal cx_Freeze slice
if: matrix.label == 'macos'
run: |
set -euo pipefail
# The Rosetta (x86_64) Homebrew lives at /usr/local/bin/brew on
# Apple Silicon GitHub runners. libyaml must be available as
# x86_64 so PyYAML's C extension (_yaml.cpython-3xx-darwin.so)
# compiles for the darwin-x64 cx_Freeze slice. Without this,
# pip falls back to pure Python pyyaml, which is absent from
# the x64 tree while the arm64 tree has the binary, causing
# unify-backend-plain-files.sh to fail.
if [[ -x /usr/local/bin/brew ]]; then
arch -x86_64 /usr/local/bin/brew install libyaml || true
else
echo "x86_64 Homebrew not found at /usr/local/bin/brew; PyYAML C extension may fall back to pure Python for x64 slice."
fi
- name: Install project deps into x64 Python (mac universal cx_Freeze)
if: matrix.label == 'macos'
env:
PY_X64: ${{ steps.python_x64.outputs.python-path }}
ARCHFLAGS: "-arch x86_64"
PKG_CONFIG_PATH: "/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig"
run: |
set -euo pipefail
arch -x86_64 "$PY_X64" -m pip install -U pip setuptools wheel
+10 -3
View File
@@ -27,6 +27,7 @@ fi
unified=0
synced=0
dropped=0
copy_missing() {
local src_dir="$1" dst_dir="$2" label="$3"
@@ -37,10 +38,13 @@ copy_missing() {
local ft
ft=$(file --brief --no-pad "$src_file" 2>/dev/null || true)
if [[ "$ft" == Mach-O* ]]; then
echo "unify-backend: refusing to copy Mach-O across architecture trees: $rel" >&2
echo "unify-backend: dropping arch-only Mach-O for consistency: $rel" >&2
echo " ($label); source reports: $ft" >&2
echo " Fix the cx_Freeze build for ${dst_dir##*/} (darwin-x64 needs x86_64 Python: PYTHON_CMD / PYTHON_CMD_X64)." >&2
exit 1
echo " Hint: ensure libyaml is available for x86_64 (arch -x86_64 brew install libyaml)" >&2
echo " so PyYAML's C extension compiles for darwin-x64 and both trees match." >&2
rm -f "$src_file"
dropped=$((dropped + 1))
continue
fi
mkdir -p "$dst_dir/$(dirname "$rel")"
cp "$src_file" "$dst_dir/$rel"
@@ -75,6 +79,9 @@ while IFS= read -r -d '' rel; do
done < <(cd "$ARM64_DIR" && find . -type f -print0)
total=$((unified + synced))
if [[ $dropped -gt 0 ]]; then
echo "unify-backend: WARNING: dropped $dropped arch-only Mach-O binary/binaries for consistency (pure Python fallback active)"
fi
if [[ $total -gt 0 ]]; then
echo "unify-backend: synced $synced missing file(s), unified $unified differing file(s)"
else