Skip to content

Commit de8f49f

Browse files
committed
Make sure CI install pytest (via pip3) and wrap pytest invocation with CMake option
Signed-off-by: hyi18 <[email protected]>
1 parent 698d319 commit de8f49f

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
shell: bash
6666
run: |
6767
sudo yum install --setopt=tsflags=nodocs -y eigen3-devel ceres-solver-devel json-devel
68-
sudo python -m pip install nanobind
68+
sudo python -m pip install nanobind pytest
6969
7070
- name: Configure CMake
7171
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
@@ -153,7 +153,7 @@ jobs:
153153
shell: bash
154154
run: |
155155
sudo yum install --setopt=tsflags=nodocs -y eigen3-devel ceres-solver-devel json-devel
156-
sudo python -m pip install nanobind
156+
sudo python -m pip install nanobind pytest
157157
158158
- name: Configure CMake
159159
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.

build_scripts/install_deps_linux.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ time sudo apt-get -q -f install -y \
1010
libopencv-dev \
1111
openimageio-tools libopenimageio-dev \
1212
nanobind-dev
13+
14+
pip3 install pytest

build_scripts/install_deps_mac.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
set -ex
44

55
brew install ceres-solver nlohmann-json openimageio nanobind robin-map
6+
7+
python3 -m pip install --break-system-packages pytest

build_scripts/install_deps_windows.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ vcpkg install \
77
nlohmann-json:x64-windows \
88
openimageio:x64-windows \
99
nanobind:x64-windows
10+
11+
pip install pytest

tests/CMakeLists.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,20 @@ add_test ( NAME Test_ImageConverter COMMAND Test_ImageConverter )
202202

203203
################################################################################
204204
# Python tests
205-
find_program(PYTHON_EXECUTABLE python3)
206-
if(PYTHON_EXECUTABLE)
207-
add_test(
208-
NAME Test_Python_ImageConverter
209-
COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/python/test_image_converter.py -v
210-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
211-
)
212-
213-
# Set environment for Python test to find the compiled module
214-
set_tests_properties(Test_Python_ImageConverter PROPERTIES
215-
ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/bindings:$ENV{PYTHONPATH}"
216-
)
205+
if(RTA_BUILD_PYTHON_BINDINGS)
206+
find_program(PYTHON_EXECUTABLE python3)
207+
if(PYTHON_EXECUTABLE)
208+
add_test(
209+
NAME Test_Python_ImageConverter
210+
COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/python/test_image_converter.py -v
211+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
212+
)
213+
214+
# Set environment for Python test to find the compiled module
215+
set_tests_properties(Test_Python_ImageConverter PROPERTIES
216+
ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/bindings:$ENV{PYTHONPATH}"
217+
)
218+
endif()
217219
endif()
218220

219221
################################################################################

0 commit comments

Comments
 (0)