Add bcond for tests

This commit is contained in:
Miro Hrončok 2020-05-25 22:15:53 +02:00
parent e3cb2b8111
commit d6c7e261f5

View File

@ -4,6 +4,9 @@
# https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Header_Only_Libraries
%global debug_package %{nil}
# Whether to run the tests, enabled by default
%bcond_without tests
%if 0%{?fedora} >= 30
%global python2_enabled 0
%else
@ -29,20 +32,24 @@ Patch1: pybind11-2.5.0-hpath.patch
BuildRequires: python2-devel
BuildRequires: python2-setuptools
# These are only needed for the checks
%if %{with tests}
BuildRequires: python2-pytest
BuildRequires: python2-numpy
BuildRequires: python2-scipy
%endif
%endif
%if %{python3_enabled}
# Needed to build the python libraries
BuildRequires: python3-devel
BuildRequires: python3-setuptools
# These are only needed for the checks
%if %{with tests}
BuildRequires: python3-pytest
BuildRequires: python3-numpy
BuildRequires: python3-scipy
%endif
%endif
BuildRequires: eigen3-devel
BuildRequires: gcc-c++
@ -113,7 +120,7 @@ pys="$pys python3"
for py in $pys; do
mkdir $py
cd $py
%cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=%{_bindir}/$py -DPYBIND11_INSTALL=TRUE -DUSE_PYTHON_INCLUDE_DIR=FALSE
%cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=%{_bindir}/$py -DPYBIND11_INSTALL=TRUE -DUSE_PYTHON_INCLUDE_DIR=FALSE %{!?with_tests:-DPYBIND11_TEST=OFF}
make %{?_smp_mflags}
cd ..
done
@ -125,6 +132,7 @@ done
%py3_build
%endif
%if %{with tests}
%check
%if %{python2_enabled}
make -C python2 check %{?_smp_mflags}
@ -132,6 +140,7 @@ make -C python2 check %{?_smp_mflags}
%if %{python3_enabled}
make -C python3 check %{?_smp_mflags}
%endif
%endif
%install
# Doesn't matter if both installs run