Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Enable selection of a specific python impl #787

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down