diff --git a/CMakeLists.txt b/CMakeLists.txt index f18c41dd1b..eeacaaa734 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,20 +223,26 @@ if(ENABLE_TESTS) find_package(Libcheck REQUIRED) # Used to generate the test files and for the application feature test framework - find_package(Python3 REQUIRED) + # In distros that support multiple implementations of python it is helpful to specify the impl to use + if(DEFINED PYTHON_FIND_VERSION) + find_package(Python3 EXACT ${PYTHON_FIND_VERSION} REQUIRED) + else() + find_package(Python3 REQUIRED) + # Not requesting a specific python impl; try using pytest from the PATH + execute_process( + COMMAND pytest --version + RESULT_VARIABLE PYTEST_EXIT_CODE + ERROR_QUIET OUTPUT_QUIET + ) - # First try using pytest from the PATH - execute_process( - COMMAND pytest --version - RESULT_VARIABLE PYTEST_EXIT_CODE - ERROR_QUIET OUTPUT_QUIET - ) + if(${PYTEST_EXIT_CODE} EQUAL 0) + # pytest found in the path. + set(PythonTest_COMMAND "pytest;-v") + endif() + endif() - if(${PYTEST_EXIT_CODE} EQUAL 0) - # pytest found in the path. - set(PythonTest_COMMAND "pytest;-v") - else() - # Not in the path, try using: python3 -m pytest + if("${PythonTest_COMMAND}" STREQUAL "") + # Not in the path or specified a python impl; try using: python3 -m pytest execute_process( COMMAND ${Python3_EXECUTABLE} -m pytest --version RESULT_VARIABLE PYTEST_MODULE_EXIT_CODE diff --git a/INSTALL.md b/INSTALL.md index eceac07896..14a4886118 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -89,6 +89,11 @@ For Maintainer-mode only (not recommended): - Bison - Gperf +On systems with multiple implementations of build-time tools it may be +desirable to select a specific implementation to use rather than relying on +CMake's logic. See [Custom CMake Config Options](#custom-cmake-config-options) +for information on this topic. + ### External Library Dependencies For installation instructions, see our online documentation: @@ -505,6 +510,11 @@ The following is a complete list of CMake options unique to configuring ClamAV: _Default: not set_ +- `PYTHON_FIND_VER`: Select a specific implementation of Python that will + be called during the test phase. + + _Default: not set_ + - `RUST_COMPILER_TARGET`: Use a custom target triple to build the Rust components. Needed for cross-compiling. You must also have installed the target toolchain. See: https://doc.rust-lang.org/nightly/rustc/platform-support.html