Blob Blame History Raw
%global desc \
FSLeyes, the FSL image viewer

# PyPi tar does not include tests
# Upstream says the tests, since they use xvfb etc., may not always pass on all
# platforms.
%bcond_with xvfb_tests

%global forgeurl

Name:           python-fsleyes
Version:        1.5.0
Release:        %autorelease
Summary:        FSLeyes, the FSL image viewer

%global tag %{version}

License:        ASL 2.0
URL:            %forgeurl
Source0:        %forgesource

BuildArch:      noarch


%package -n python3-fsleyes
Summary:        %{summary}
BuildRequires:  python3-devel
BuildRequires:  /usr/bin/desktop-file-install
BuildRequires:  /usr/bin/appstream-util
Requires:       hicolor-icon-theme
# from requirements-dev.txt

%if %{with xvfb_tests}
BuildRequires:  graphviz
BuildRequires:  %{py3_dist mock}
BuildRequires:  %{py3_dist pytest}
BuildRequires:  %{py3_dist pytest-cov}
BuildRequires:  %{py3_dist wxpython}
BuildRequires:  freeglut-devel
BuildRequires:  xorg-x11-server-Xvfb
BuildRequires:  python3-matplotlib-wx

Requires:       dcm2niix
Requires:       python3-matplotlib-wx

Provides:       fsleyes = %{version}-%{release}

%description -n python3-fsleyes


# remove jinja version fix
sed -i 's/jinja2.*/jinja2/' requirements.txt
# relax required pyparsing version
sed -i 's/pyparsing==2.\*/pyparsing/' requirements.txt
# extras: not yet packaged in Fedora
sed -i '/file-tree/ d' requirements-extra.txt
# Add extra requirements for autogenerator
cat requirements-extra.txt >> requirements.txt
cat requirements-notebook.txt >> requirements.txt

# Remove unnecessary upper limit on Pillow:
# sed -i 's/\(Pillow>=3.2.0\),.*/\1/' requirements.txt

# remove unneeded shebangs
find . -name "*py" -exec sed -i '/#!\/usr\/bin\/env python/ d' '{}' \;

%pyproject_buildrequires -r requirements.txt requirements-dev.txt


%pyproject_save_files fsleyes

# install desktop file in correct location
desktop-file-install --dir=%{buildroot}%{_datadir}/applications fsleyes/assets/linux/
rm -f %{python3_sitelib}/fsleyes/assets/linux/

# install appdata file
install -p -m 0644 -D -t %{buildroot}%{_metainfodir} fsleyes/assets/linux/
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*FSLeyes*xml

rm -f %{python3_sitelib}/fsleyes/assets/linux/

# install icons to the right place
pushd fsleyes/assets/icons/app_icon/fsleyes.iconset/
for size in 16 32 128 256 512
install -p -m 0755 -D -T "icon_${size}x${size}.png" %{buildroot}%{_datadir}/icons/hicolor/"${size}x${size}"/apps/fsleyes.png
# do these manually
install -p -m 0755 -D -T icon_32x32@2x.png %{buildroot}%{_datadir}/icons/hicolor/64x64/apps/fsleyes.png
install -p -m 0755 -D -T icon_512x512@2x.png %{buildroot}%{_datadir}/icons/hicolor/1024x1024/apps/fsleyes.png
# 48x58 is in a different place than the others
install -p -m 0755 -D -t %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/ fsleyes/assets/linux/hicolor/48x48/apps/fsleyes.png

export MPLBACKEND=wxagg
%if %{with xvfb_tests}
export FSLEYES_TEST_GL=2.1
xvfb-run -s "-screen 0 640x480x24" pytest-%{python3_version}
sleep 10
# test overlay types for GL14 as well
export FSLEYES_TEST_GL=1.4
xvfb-run -s "-screen 0 640x480x24" pytest-%{python3_version}

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