mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 21:25:13 +00:00
Don't install pytest from cmake, just fail instead
Installing something outside the project directory from a cmake invocation is overly intrusive; this changes tests/CMakeLists.txt to just fail with an informative message instead, and changes the travis-ci builds to install pytest via pip or apt-get.
This commit is contained in:
parent
324c9c521b
commit
dd3d56a885
@ -34,7 +34,7 @@ matrix:
|
|||||||
apt:
|
apt:
|
||||||
sources: [ubuntu-toolchain-r-test, kubuntu-backports]
|
sources: [ubuntu-toolchain-r-test, kubuntu-backports]
|
||||||
packages: [g++-4.8, cmake]
|
packages: [g++-4.8, cmake]
|
||||||
install: false
|
install: pip install pytest
|
||||||
# Documentation build:
|
# Documentation build:
|
||||||
- os: linux
|
- os: linux
|
||||||
language: docs
|
language: docs
|
||||||
@ -90,10 +90,10 @@ install:
|
|||||||
# Install dependencies
|
# Install dependencies
|
||||||
if [ -n "$DOCKER" ]; then
|
if [ -n "$DOCKER" ]; then
|
||||||
docker exec --tty "$containerid" apt-get -y --no-install-recommends install \
|
docker exec --tty "$containerid" apt-get -y --no-install-recommends install \
|
||||||
python$PYTHON-dev python$PY-pip python$PY-setuptools python$PY-scipy \
|
python$PYTHON-dev python$PY-pytest python$PY-scipy \
|
||||||
libeigen3-dev cmake make g++
|
libeigen3-dev cmake make g++
|
||||||
else
|
else
|
||||||
pip install numpy scipy
|
pip install numpy scipy pytest
|
||||||
|
|
||||||
wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.2.9.tar.gz
|
wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.2.9.tar.gz
|
||||||
tar xzf eigen.tar.gz
|
tar xzf eigen.tar.gz
|
||||||
|
@ -58,7 +58,7 @@ 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
|
# Make sure pytest is found or produce a fatal error
|
||||||
macro(pybind11_execute_python)
|
macro(pybind11_execute_python)
|
||||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m ${ARGN} OUTPUT_QUIET ERROR_QUIET
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m ${ARGN} OUTPUT_QUIET ERROR_QUIET
|
||||||
RESULT_VARIABLE pybind11_execute_python_error)
|
RESULT_VARIABLE pybind11_execute_python_error)
|
||||||
@ -67,17 +67,7 @@ endmacro()
|
|||||||
if(NOT PYBIND11_PYTEST_FOUND)
|
if(NOT PYBIND11_PYTEST_FOUND)
|
||||||
pybind11_execute_python(pytest --version --noconftest)
|
pybind11_execute_python(pytest --version --noconftest)
|
||||||
if(pybind11_execute_python_error)
|
if(pybind11_execute_python_error)
|
||||||
message(STATUS "Installing pytest using pip")
|
message(FATAL_ERROR "Running the tests requires pytest. Please install it manually (try: ${PYTHON_EXECUTABLE} -m pip install pytest)")
|
||||||
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()
|
endif()
|
||||||
|
|
||||||
set(PYBIND11_PYTEST_FOUND TRUE CACHE INTERAL "")
|
set(PYBIND11_PYTEST_FOUND TRUE CACHE INTERAL "")
|
||||||
|
Loading…
Reference in New Issue
Block a user