Blame python-fslpy.spec

7739b56
# These are problematic, sometimes they randomly fail or hang
7739b56
%bcond_with xvfb_tests
7739b56
f31f6dd
%global desc \
f31f6dd
The fslpy project is a FSL programming library written in Python. It is used by \
f31f6dd
FSLeyes.
f31f6dd
fae691c
%global forgeurl https://github.com/pauldmccarthy/fslpy
fae691c
071afb7
Name:           python-fslpy
Packit dfbb2de
Version:        3.16.1
071afb7
Release:        %autorelease
f31f6dd
Summary:        The FSL Python Library
f31f6dd
fae691c
%global tag %{version}
f31f6dd
fae691c
%forgemeta
f31f6dd
fae691c
fae691c
License:        Apache-2.0
fae691c
URL:            %forgeurl
fae691c
Source0:        %forgesource
2e8aacc
f31f6dd
BuildArch:      noarch
bc4b66f
# fsleyes dropped it already, so this is a leaf package
bc4b66f
# F40+
bc4b66f
ExcludeArch:    %{ix86}
bc4b66f
f31f6dd
BuildRequires:  python3-devel
80dbf22
BuildRequires:  help2man
f31f6dd
7268dd5
BuildRequires:  dcm2niix
071afb7
BuildRequires:  %{py3_dist pytest}
071afb7
%if %{with xvfb_tests}
f31f6dd
BuildRequires:  xorg-x11-server-Xvfb
071afb7
%endif
f31f6dd
f31f6dd
f31f6dd
%description
f31f6dd
%{desc}
f31f6dd
071afb7
%package -n python3-fslpy
f31f6dd
Summary:        %{summary}
69a7f61
071afb7
%description -n python3-fslpy
f31f6dd
%{desc}
f31f6dd
bc4b66f
%pyproject_extras_subpkg -n python3-fslpy extra
69a7f61
f31f6dd
%prep
fae691c
%forgesetup
f31f6dd
fae691c
# remove pytest coverage etc bits
fae691c
sed -i -e '/"coverage"/ d' \
fae691c
    -e '/"pytest-cov"/ d' \
fae691c
    -e '/addopts/ d' \
fae691c
    pyproject.toml
69a7f61
f31f6dd
# remove unneeded shebangs
ae3d83d
find . -type f -name "*.py" -exec sed -i '/^#![  ]*\/usr\/bin\/env python$/ d' {} 2>/dev/null ';'
80dbf22
sed -i '/^#![  ]*\/usr\/bin\/env python3$/ d' fsl/wrappers/tbss.py
ae3d83d
# some scripts have the shebang, so we correct these
ae3d83d
find . -type f -name "*.py" -exec sed -i 's/#![  ]*\/usr\/bin\/env python$/#!\/usr\/bin\/python3/' {} 2>/dev/null ';'
f31f6dd
071afb7
%generate_buildrequires
fae691c
%pyproject_buildrequires -x extra -x test
071afb7
f31f6dd
%build
071afb7
%pyproject_wheel
f31f6dd
f31f6dd
%install
071afb7
%pyproject_install
071afb7
%pyproject_save_files fsl
f31f6dd
a26f2c0
# Remove test packages that are installed in site packages
bc4b66f
rm -rvf %{buildroot}%{python3_sitelib}/fsl/tests
bc4b66f
sed -r -i '/\bfsl\/tests\b/d' %{pyproject_files}
a26f2c0
80dbf22
# generate man pages
80dbf22
# imglob does not have a --help
80dbf22
for binary in "atlasq" "atlasquery" "fsl_apply_x5" "fsl_ents" "fsl_convert_x5" "imcp" "immv" "resample_image" "Text2Vest" "Vest2Text" "fsl_abspath" "imln" "imtest" "remove_ext"
80dbf22
do
80dbf22
    echo "Generating man page for ${binary// /-/}"
80dbf22
    PYTHONPATH="$PYTHONPATH:%{buildroot}/%{python3_sitelib}/" PATH="$PATH:%{buildroot}/%{_bindir}/" help2man --no-info --no-discard-stderr --name="${binary}" --version-string="${binary} %{version}" --output="${binary// /-}.1" "${binary}"
80dbf22
    cat "${binary// /-}.1"
80dbf22
    install -t '%{buildroot}%{_mandir}/man1' -p -m 0644 -D "${binary// /-}.1"
80dbf22
done
80dbf22
80dbf22
# do not have a --help
80dbf22
for binary in "imglob" "imrm"
80dbf22
do
80dbf22
    echo "Generating man page for ${binary// /-/}"
80dbf22
    PYTHONPATH="$PYTHONPATH:%{buildroot}/%{python3_sitelib}/" PATH="$PATH:%{buildroot}/%{_bindir}/" help2man --help-option=" " --no-info --no-discard-stderr --name="${binary}" --version-string="${binary} %{version}" --output="${binary// /-}.1" "${binary}"
80dbf22
    cat "${binary// /-}.1"
80dbf22
    install -t '%{buildroot}%{_mandir}/man1' -p -m 0644 -D "${binary// /-}.1"
80dbf22
done
a0915c3
071afb7
%check
7739b56
%if %{with xvfb_tests}
f31f6dd
# From https://git.fmrib.ox.ac.uk/fsl/fslpy/blob/master/.ci/test_template.sh
f31f6dd
xvfb-run pytest-3 tests/test_idle.py
f31f6dd
sleep 10
f31f6dd
# Sometimes fails, sometimes passes
69a7f61
xvfb-run pytest-3 tests/test_platform.py || exit 0
7739b56
%endif
f31f6dd
560f65e
# https://github.com/pauldmccarthy/fslpy/issues/17
f31f6dd
# Ignore tests that have already been done
f31f6dd
# Ignore immv_imcp because it requires a "nobody" user
f31f6dd
# Ignore tests that require downloading data.
f31f6dd
# Ignore tests requiring trimesh
f31f6dd
# Ignore test using dcm2niix
a6e6b92
# Ignore intermittently failing test: https://github.com/pauldmccarthy/fslpy/issues/10
a6e6b92
# Ignore submit tests
560f65e
k="not longtest and not test_submit"
560f65e
k="${k} and not test_FEATFSFDesign_firstLevelVoxelwiseEV"
560f65e
k="${k} and not test_compressed_voxelwise_ev"
560f65e
k="${k} and not test_image_readonly_compressed"
560f65e
k="${k} and not test_runfunc"
560f65e
k="${k} and not test_fslmaths_load"
560f65e
k="${k} and not test_fileOrImage"
560f65e
k="${k} and not test_fileOrThing_outprefix"
560f65e
k="${k} and not test_fileOrThing_outprefix_pathlib"
560f65e
k="${k} and not test_fileOrThing_outprefix_differentTypes"
560f65e
k="${k} and not test_fileOrThing_outprefix_directory"
560f65e
k="${k} and not test_chained_fileOrImageAndArray"
560f65e
k="${k} and not test_fileOrThing_submit_cmdonly"
560f65e
k="${k} and not test_fileOrImage_all_tempfiles_cleared"
560f65e
k="${k} and not test_atlas"
560f65e
k="${k} and not test_read_nifti"
560f65e
k="${k} and not test_VoxelwiseEVs"
560f65e
k="${k} and not test_imcp_shouldPass"
560f65e
k="${k} and not test_immv_shouldPass"
560f65e
k="${k} and not test_fileOrThing_chained_outprefix"
fae691c
# requires an FSL installation
fae691c
k="${k} and not test_cluster"
fae691c
# unable to find tests module
fae691c
k="${k} and not test_func_to_cmd"
fae691c
%{pytest} fsl/tests  -k "${k}" \
fae691c
  --ignore=fsl/tests/test_idle.py --ignore=fsl/tests/test_platform.py \
fae691c
  --ignore=fsl/tests/test_atlases.py \
fae691c
  --ignore=fsl/tests/test_atlases_query.py \
fae691c
  --ignore=fsl/tests/test_scripts/test_atlasq_list_summary.py \
fae691c
  --ignore=fsl/tests/test_scripts/test_atlasq_ohi.py \
fae691c
  --ignore=fsl/tests/test_scripts/test_atlasq_query.py \
fae691c
  --ignore=fsl/tests/test_dicom.py \
fae691c
  --ignore=fsl/tests/test_scripts/test_fsl_apply_x5.py \
fae691c
  --ignore=fsl/tests/test_scripts/test_fsl_convert_x5.py \
fae691c
  --ignore=fsl/tests/test_scripts/test_immv_imcp.py
a0915c3
071afb7
%files -n python3-fslpy -f %{pyproject_files}
f31f6dd
%doc README.rst
f31f6dd
%{_bindir}/atlasq
f31f6dd
%{_bindir}/atlasquery
257130a
%{_bindir}/fsl_apply_x5
f31f6dd
%{_bindir}/fsl_ents
257130a
%{_bindir}/fsl_convert_x5
f31f6dd
%{_bindir}/imcp
f31f6dd
%{_bindir}/imglob
f31f6dd
%{_bindir}/immv
69a7f61
%{_bindir}/resample_image
0473c5f
%{_bindir}/Text2Vest
0473c5f
%{_bindir}/Vest2Text
0473c5f
%{_bindir}/fsl_abspath
0473c5f
%{_bindir}/imln
0473c5f
%{_bindir}/imrm
0473c5f
%{_bindir}/imtest
0473c5f
%{_bindir}/remove_ext
80dbf22
%{_mandir}/man1/*.*
f31f6dd
f31f6dd
%changelog
071afb7
%autochangelog