@@ -7,82 +7,84 @@ endif()
77
88# Find Python 3 installed on the system.
99find_package (Python3 COMPONENTS Interpreter)
10- if (Python3_FOUND)
11- message ( STATUS "Setting up Python virtual environment" )
12- list ( APPEND CMAKE_MESSAGE_INDENT " " )
10+ if (NOT Python3_FOUND)
11+ return ( )
12+ endif ( )
1313
14- # Create a virtual environment using the system Python.
15- set (ENV{VIRTUAL_ENV} "${CMAKE_CURRENT_BINARY_DIR} /venv" )
16- execute_process (
17- COMMAND
18- "${Python3_EXECUTABLE} "
19- -m venv
20- "${CMAKE_CURRENT_BINARY_DIR} /venv"
21- )
14+ message (STATUS "Setting up Python virtual environment" )
15+ list (APPEND CMAKE_MESSAGE_INDENT " " )
2216
23- # Forget about the system Python version; look for Python 3 installed within
24- # the virtual environment now.
25- set (Python3_FIND_VIRTUALENV FIRST)
26- unset (Python3_EXECUTABLE)
27- find_package (Python3 COMPONENTS Interpreter)
17+ # Create a virtual environment using the system Python.
18+ set (ENV{VIRTUAL_ENV} "${CMAKE_CURRENT_BINARY_DIR} /venv" )
19+ execute_process (
20+ COMMAND
21+ "${Python3_EXECUTABLE} "
22+ -m venv
23+ "${CMAKE_CURRENT_BINARY_DIR} /venv"
24+ )
2825
29- # Upgrade virtual environment pip and install required dependencies.
30- message (STATUS "Upgrade virtual environment pip" )
31- execute_process (
32- COMMAND
33- "${Python3_EXECUTABLE} "
34- -m pip
35- install
36- --quiet
37- --upgrade
38- pip
39- )
40- message (STATUS "Install dependencies into virtual environment" )
41- execute_process (
42- COMMAND
43- "${Python3_EXECUTABLE} "
44- -m pip
45- install
46- --quiet
47- -r "${CMAKE_CURRENT_SOURCE_DIR} /../python/requirements.txt"
48- )
26+ # Forget about the system Python version; look for Python 3 installed within
27+ # the virtual environment now.
28+ set (Python3_FIND_VIRTUALENV FIRST)
29+ unset (Python3_EXECUTABLE)
30+ find_package (Python3 COMPONENTS Interpreter)
4931
50- # Use pytest-cmake from pypi to integrate pytest integration tests as CTest
51- # targets.
52- message (STATUS "Install pytest-cmake into virtual environment" )
53- execute_process (
54- COMMAND
55- "${Python3_EXECUTABLE} "
32+ # Upgrade virtual environment pip and install required dependencies.
33+ message (STATUS "Upgrade virtual environment pip" )
34+ execute_process (
35+ COMMAND
36+ "${Python3_EXECUTABLE} "
37+ -m pip
38+ install
39+ --quiet
40+ --upgrade
41+ pip
42+ )
43+ message (STATUS "Install dependencies into virtual environment" )
44+ execute_process (
45+ COMMAND
46+ "${Python3_EXECUTABLE} "
5647 -m pip
5748 install
5849 --quiet
59- pytest-cmake
60- )
61- list (PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR} /venv/share/Pytest/cmake" )
62- set (Pytest_ROOT "${CMAKE_CURRENT_BINARY_DIR} /venv/bin" )
63- find_package (Pytest)
50+ -r "${CMAKE_CURRENT_SOURCE_DIR} /../python/requirements.txt"
51+ )
6452
65- # If everything went well, we can use `pytest_discover_tests` to construct
66- # CTest targets for each integration test.
67- if (Pytest_FOUND)
68- message (STATUS "Adding integration tests to CTest" )
53+ # Use pytest-cmake from pypi to integrate pytest integration tests as CTest
54+ # targets.
55+ message (STATUS "Install pytest-cmake into virtual environment" )
56+ execute_process (
57+ COMMAND
58+ "${Python3_EXECUTABLE} "
59+ -m pip
60+ install
61+ --quiet
62+ pytest-cmake
63+ )
64+ list (PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR} /venv/share/Pytest/cmake" )
65+ set (Pytest_ROOT "${CMAKE_CURRENT_BINARY_DIR} /venv/bin" )
66+ find_package (Pytest)
6967
70- file (GLOB_RECURSE integration_test_files "*.py" )
71- pytest_discover_tests(
72- all .it
73- ENVIRONMENT
74- "BLAZINGMQ_BUILD_DIR=${CMAKE_BINARY_DIR} "
75- PYTHON_PATH_PREPEND
76- "${CMAKE_SOURCE_DIR} /src/python/"
77- STRIP_PARAM_BRACKETS
78- TRIM_FROM_NAME
79- "^test_"
80- DEPENDS
81- bmqbrkr bmqtool ${integration_test_files}
82- PROPERTIES
83- LABELS "integration;all"
84- )
85- endif ()
68+ # If everything went well, we can use `pytest_discover_tests` to construct
69+ # CTest targets for each integration test.
70+ if (Pytest_FOUND)
71+ message (STATUS "Adding integration tests to CTest" )
8672
87- list (POP_BACK CMAKE_MESSAGE_INDENT)
73+ file (GLOB_RECURSE integration_test_files "*.py" )
74+ pytest_discover_tests(
75+ all .it
76+ ENVIRONMENT
77+ "BLAZINGMQ_BUILD_DIR=${CMAKE_BINARY_DIR} "
78+ PYTHON_PATH_PREPEND
79+ "${CMAKE_SOURCE_DIR} /src/python/"
80+ STRIP_PARAM_BRACKETS
81+ TRIM_FROM_NAME
82+ "^test_"
83+ DEPENDS
84+ bmqbrkr bmqtool ${integration_test_files}
85+ PROPERTIES
86+ LABELS "integration;all"
87+ )
8888endif ()
89+
90+ list (POP_BACK CMAKE_MESSAGE_INDENT)
0 commit comments