From fe22c53f1761dce60d41a1eca8729dc72b88cfd2 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 7 May 2026 17:18:35 -0700 Subject: [PATCH] build(cmake): probe kconfiglib via import kconfiglib not menuconfig cmake/kconfig.cmake verified that kconfiglib is installed by running `python -c "import menuconfig"`. The `menuconfig` entry point pulls in the standard library `curses` module, which is missing on a number of hosts we care about: - the macOS arm64 hostedtoolcache Python (3.10.11) used by the `MacOS build` job, which now fails the kconfiglib check during cmake configure of px4_sitl_default - any Windows Python that does not have windows-curses installed (kconfiglib stopped pulling it in automatically at 13.0) We never invoke menuconfig from the build itself - only the standalone `make menuconfig` developer target does, and there the curses dependency is unavoidable. Probe with `import kconfiglib` instead, so configure succeeds anywhere kconfiglib (the actual dependency) is importable. Also tighten the failure check to `NOT ret EQUAL "0"` so non-zero return codes other than 1 are caught. Signed-off-by: Nuno Marques --- cmake/kconfig.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index 898f17c0b5a..8c5f9807a05 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -1,8 +1,14 @@ set(BOARD_DEFCONFIG ${PX4_CONFIG_FILE} CACHE FILEPATH "path to defconfig" FORCE) set(BOARD_CONFIG ${PX4_BINARY_DIR}/boardconfig CACHE FILEPATH "path to config" FORCE) -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import menuconfig" RESULT_VARIABLE ret) -if(ret EQUAL "1") +# Verify kconfiglib presence by importing the package itself rather than +# the `menuconfig` entry point. `menuconfig` pulls in the standard +# `curses` module which is not shipped on every Python install (e.g. the +# setup-python interpreter on Windows runners, or some hostedtoolcache +# Pythons on macOS), and we only need kconfiglib for non-interactive +# config generation here. +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import kconfiglib" RESULT_VARIABLE ret) +if(NOT ret EQUAL "0") message(FATAL_ERROR "kconfiglib is not installed or not in PATH\n" "please install using \"pip3 install kconfiglib\"\n") endif()