Skip to content

Commit 514f2da

Browse files
committed
ci(distributions): smoke test the Intel macOS wheels with Python running as x86_64
setup-python's x64 CPython for macOS is a universal2 build, so on the Apple silicon runner it runs as arm64 and pip refuses the macosx x86_64 wheels. The smoke test now runs that Python through arch -x86_64 under Rosetta 2, and fails first if it does not report an x86_64 machine.
1 parent 279e7a8 commit 514f2da

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎.github/workflows/build-distributions.yml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,32 @@ jobs:
260260
github-token: ${{ github.token }}
261261
- name: Smoke test the installed wheels as the site's quick start runs them
262262
shell: bash
263+
env:
264+
PYTHON_ARCH: ${{ matrix.platform.python-arch }}
263265
run: |
264266
python -m venv "${RUNNER_TEMP}/wheel-smoke"
265267
if [[ -x "${RUNNER_TEMP}/wheel-smoke/Scripts/python.exe" ]]; then
266268
bin="${RUNNER_TEMP}/wheel-smoke/Scripts"
267269
else
268270
bin="${RUNNER_TEMP}/wheel-smoke/bin"
269271
fi
272+
python=("${bin}/python")
273+
# setup-python's x64 CPython for macOS is universal2 and runs as arm64 on Apple silicon,
274+
# where pip would refuse the Intel wheels; run it as x86_64 under Rosetta 2 instead.
275+
if [[ "${PYTHON_ARCH}" == "x64" && "${RUNNER_OS}" == "macOS" ]]; then
276+
python=(arch -x86_64 "${bin}/python")
277+
machine="$("${python[@]}" -c "import platform; print(platform.machine())")"
278+
if [[ "${machine}" != "x86_64" ]]; then
279+
echo "The smoke test Python runs as ${machine}, not x86_64" >&2
280+
exit 1
281+
fi
282+
fi
270283
ls -l dist | tee -a "${GITHUB_STEP_SUMMARY}"
271284
# Only the wheels just built: sqlquack-cli must resolve from dist, never from an index.
272-
"${bin}/python" -m pip install --no-index --find-links dist sqlquack
285+
"${python[@]}" -m pip install --no-index --find-links dist sqlquack
273286
cd "${RUNNER_TEMP}"
274287
"${bin}/sqlquack" --version
275-
"${bin}/python" -c "import sqlquack.api"
288+
"${python[@]}" -c "import sqlquack.api"
276289
set +e
277290
check="$(echo "SELECT 1 QUALIFY TRUE" | "${bin}/sqlquack" check 2>&1)"
278291
status=$?
@@ -301,7 +314,7 @@ jobs:
301314
echo "${ran}"
302315
grep -q '^2 *1.25$' <<< "${ran}"
303316
# The README's Python example.
304-
"${bin}/python" -c 'import sqlquack
317+
"${python[@]}" -c 'import sqlquack
305318
result = sqlquack.convert(sql="SELECT 1 AS total", options=sqlquack.ConvertOptions(no_config=True))
306319
assert result.sql == "SELECT CAST(1 AS DECIMAL(1,0)) AS \"TOTAL\"", result.sql'
307320
- uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)