ci(macos): point cmake at the venv created by setup script

The MacOS build job calls actions/setup-python before running
Tools/setup/macos.sh, which creates a venv at .venv and installs all
of PX4's Python deps (kconfiglib, empy, etc.) there. setup-python
exports Python3_ROOT_DIR / Python_ROOT_DIR / pythonLocation pointing
at the hostedtoolcache interpreter, and find_package(Python3) honours
those hints over PATH search even with FIND_STRATEGY=LOCATION. Adding
.venv/bin to GITHUB_PATH was therefore not enough -- cmake kept
selecting /Users/runner/hostedtoolcache/Python/3.10.11/arm64/bin/python3.10,
which has no kconfiglib, and configure failed at cmake/kconfig.cmake's
import probe.

Override Python3_ROOT_DIR / Python_ROOT_DIR / pythonLocation to the
.venv and export VIRTUAL_ENV so Python3_FIND_VIRTUALENV=FIRST kicks in,
making the venv interpreter the one cmake picks up.

Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
Nuno Marques
2026-05-07 16:40:13 -07:00
parent b463416559
commit 7be68c5ebc
+11
View File
@@ -46,7 +46,18 @@ jobs:
- name: setup
run: |
./Tools/setup/macos.sh
# Make the venv created by macos.sh the active Python for all
# subsequent steps. Prepending .venv/bin to PATH alone is not
# enough: actions/setup-python exports Python3_ROOT_DIR /
# pythonLocation pointing at the hostedtoolcache interpreter,
# and find_package(Python3) honours those hints over PATH. The
# PX4 Python deps (kconfiglib, empy, etc.) only live in the
# venv, so configure fails at the kconfiglib import otherwise.
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=${{ github.workspace }}/.venv" >> $GITHUB_ENV
echo "Python3_ROOT_DIR=${{ github.workspace }}/.venv" >> $GITHUB_ENV
echo "Python_ROOT_DIR=${{ github.workspace }}/.venv" >> $GITHUB_ENV
echo "pythonLocation=${{ github.workspace }}/.venv" >> $GITHUB_ENV
- uses: ./.github/actions/setup-ccache
id: ccache