Blob Blame History Raw
# These are problematic, sometimes they randomly fail or hang
%bcond_with xvfb_tests

%global desc \
The fslpy project is a FSL programming library written in Python. It is used by \

Name:           python-fslpy
Version:        3.10.0
Release:        %autorelease
Summary:        The FSL Python Library

License:        ASL 2.0
Source0:        %{pypi_source fslpy}

BuildArch:      noarch
BuildRequires:  python3-devel

BuildRequires:  dcm2niix
BuildRequires:  %{py3_dist pytest}
BuildRequires:  %{py3_dist pytest-cov}
%if %{with xvfb_tests}
BuildRequires:  xorg-x11-server-Xvfb


%package -n python3-fslpy
Summary:        %{summary}

%description -n python3-fslpy

%autosetup -n fslpy-%{version}

# For the dep generator to pick up
cat requirements-extra.txt >> requirements.txt

# remove unneeded shebangs
find . -type f -name "*.py" -exec sed -i '/^#![  ]*\/usr\/bin\/env python$/ d' {} 2>/dev/null ';'
# some scripts have the shebang, so we correct these
find . -type f -name "*.py" -exec sed -i 's/#![  ]*\/usr\/bin\/env python$/#!\/usr\/bin\/python3/' {} 2>/dev/null ';'

%pyproject_buildrequires -r


%pyproject_save_files fsl

# Remove test packages that are installed in site packages
rm -rfv %{buildroot}/%{python3_sitelib}/tests/

%if %{with xvfb_tests}
# From
xvfb-run pytest-3 tests/
sleep 10
# Sometimes fails, sometimes passes
xvfb-run pytest-3 tests/ || exit 0

# Ignore tests that have already been done
# Ignore immv_imcp because it requires a "nobody" user
# Ignore tests that require downloading data.
# Ignore tests requiring trimesh
# Ignore test using dcm2niix
# Ignore intermittently failing test:
# Ignore submit tests
%{pytest} tests  -m "not longtest and not test_submit" \
  --ignore=tests/ --ignore=tests/ \
  --ignore=tests/ --ignore=tests/ \
  --ignore=tests/ \
  --ignore=tests/test_scripts/ \
  --ignore=tests/test_scripts/ \
  --ignore=tests/test_scripts/ --ignore=tests/ \
  --ignore=tests/ --ignore=tests/ \
  --ignore=tests/ \

%files -n python3-fslpy -f %{pyproject_files}
%doc README.rst