mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
Automatically install pytest from CMake
Pytest is a development dependency but we can make it painless by automating the install using CMake.
This commit is contained in:
parent
a9a37b4e31
commit
18319d5598
@ -39,7 +39,7 @@ matrix:
|
|||||||
install:
|
install:
|
||||||
- >
|
- >
|
||||||
docker exec --tty "$containerid" apt-get -y --no-install-recommends install
|
docker exec --tty "$containerid" apt-get -y --no-install-recommends install
|
||||||
python2.7-dev python-scipy libeigen3-dev
|
python2.7-dev python-pip python-setuptools python-scipy libeigen3-dev
|
||||||
cmake make g++
|
cmake make g++
|
||||||
- compiler: gcc-6
|
- compiler: gcc-6
|
||||||
services: docker
|
services: docker
|
||||||
@ -48,7 +48,7 @@ matrix:
|
|||||||
install:
|
install:
|
||||||
- >
|
- >
|
||||||
docker exec --tty "$containerid" apt-get -y --no-install-recommends install
|
docker exec --tty "$containerid" apt-get -y --no-install-recommends install
|
||||||
python3.5-dev python3-scipy libeigen3-dev
|
python3.5-dev python3-pip python3-setuptools python3-scipy libeigen3-dev
|
||||||
cmake make g++
|
cmake make g++
|
||||||
# Documentation build:
|
# Documentation build:
|
||||||
- os: linux
|
- os: linux
|
||||||
|
@ -58,6 +58,31 @@ if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Make sure pytest is found or try to install it if it's not found
|
||||||
|
macro(pybind11_execute_python)
|
||||||
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m ${ARGN} OUTPUT_QUIET ERROR_QUIET
|
||||||
|
RESULT_VARIABLE pybind11_execute_python_error)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
if(NOT PYBIND11_PYTEST_FOUND)
|
||||||
|
pybind11_execute_python(pytest --version --noconftest)
|
||||||
|
if(pybind11_execute_python_error)
|
||||||
|
message(STATUS "Installing pytest using pip")
|
||||||
|
pybind11_execute_python(pip install pytest)
|
||||||
|
if(pybind11_execute_python_error)
|
||||||
|
message(STATUS "Installing pytest using pip --user (fallback)")
|
||||||
|
pybind11_execute_python(pip install --user pytest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
pybind11_execute_python(pytest --version --noconftest)
|
||||||
|
if(pybind11_execute_python_error)
|
||||||
|
message(FATAL_ERROR "Running the tests requires pytest. Please install it manually.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PYBIND11_PYTEST_FOUND TRUE CACHE INTERAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
# A single command to compile and run the tests
|
# A single command to compile and run the tests
|
||||||
add_custom_target(pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest
|
add_custom_target(pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest -rws
|
||||||
DEPENDS pybind11_tests WORKING_DIRECTORY ${testdir})
|
DEPENDS pybind11_tests WORKING_DIRECTORY ${testdir})
|
||||||
|
Loading…
Reference in New Issue
Block a user