From 03069b5f4515505497aa88042b85db12d9046929 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Wed, 25 Nov 2026 11:48:29 -0700 Subject: [PATCH] Set Python{,3}_CROSSCOMPILING_EMULATOR in CMAKE_ARGS CMake >= 4.1 with policy CMP0190 errors out when cross-compiling and FindPython is asked for Interpreter together with Development components unless an emulator is defined. The python in $PREFIX is a shim that runs natively, so define the emulator as empty. --- recipe/activate-cross-python.sh | 7 +++++++ recipe/deactivate-cross-python.sh | 4 ++++ recipe/recipe.yaml | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/recipe/activate-cross-python.sh b/recipe/activate-cross-python.sh index bd2eb1a..40425f6 100644 --- a/recipe/activate-cross-python.sh +++ b/recipe/activate-cross-python.sh @@ -126,5 +126,12 @@ if [[ "${CONDA_BUILD:-0}" == "1" && "${CONDA_BUILD_STATE}" != "TEST" ]]; then fi unset sysconfigdata_fn export PYTHONPATH=$BUILD_PREFIX/venv/lib/python@PY_VER@@PY_THREAD@/site-packages + # CMake >= 4.1 (policy CMP0190) refuses to look for the Python interpreter together with + # Development components when cross-compiling unless an emulator is defined. The python + # in $PREFIX is a shim that runs natively, so define the emulator as empty. + if [[ "${CMAKE_ARGS:-}" != *"Python3_CROSSCOMPILING_EMULATOR"* ]]; then + export _CONDA_BACKUP_CROSS_PYTHON_CMAKE_ARGS="${CMAKE_ARGS:-}" + export CMAKE_ARGS="${CMAKE_ARGS:-} -DPython_CROSSCOMPILING_EMULATOR= -DPython3_CROSSCOMPILING_EMULATOR=" + fi echo "Finished setting up cross-python" fi diff --git a/recipe/deactivate-cross-python.sh b/recipe/deactivate-cross-python.sh index be9e644..22894ee 100644 --- a/recipe/deactivate-cross-python.sh +++ b/recipe/deactivate-cross-python.sh @@ -5,4 +5,8 @@ if [[ "${CONDA_BUILD:-0}" == "1" && "${CONDA_BUILD_STATE}" != "TEST" ]]; then if [[ "${_CONDA_BACKUP_PYTHONPATH}" != "" ]]; then export PYTHONPATH=${_CONDA_BACKUP_PYTHONPATH} fi + if [[ -n "${_CONDA_BACKUP_CROSS_PYTHON_CMAKE_ARGS+x}" ]]; then + export CMAKE_ARGS="${_CONDA_BACKUP_CROSS_PYTHON_CMAKE_ARGS}" + unset _CONDA_BACKUP_CROSS_PYTHON_CMAKE_ARGS + fi fi diff --git a/recipe/recipe.yaml b/recipe/recipe.yaml index 45ed219..29950f3 100644 --- a/recipe/recipe.yaml +++ b/recipe/recipe.yaml @@ -1,7 +1,7 @@ schema_version: 1 context: - build_number: 56 + build_number: 57 package: name: cross-python_${{ cross_target_platform|default("linux-64") }}