Blob Blame History Raw
%bcond_without tests

%global _description %{expand:
PyPlane is a free software for phase plane analysis of second order dynamical
systems written in PYTHON and PyQT5. Comparable to MATLAB's pplane.}

%global forgeurl https://github.com/TUD-RST/pyplane

Name:           pyplane
Version:        2.0.0
Summary:        Phase plane analysis of nonlinear systems

%global  tag PyPlane_v%{version}
%forgemeta

Release:        %autorelease
License:        GPLv3
URL:            %{forgeurl}
Source0:        %{forgesource}
# Sent upstream https://github.com/TUD-RST/pyplane/pull/9
Source1:        pyplane.metainfo.xml
Source2:        pyplane.desktop

# Write logging file to XDG_DATA_HOME instead of /usr/lib/pythonX.Y/site-packages/
# https://github.com/TUD-RST/pyplane/pull/10
Patch0:         0001-feat-use-XDG_DATA_HOME-for-logging-file-on-Linux.patch

BuildArch:      noarch

BuildRequires:  git-core
BuildRequires:  python3-devel
BuildRequires:  libappstream-glib
BuildRequires:  desktop-file-utils
%if %{with tests}
BuildRequires:  %{py3_dist pytest}
# bits not mentioned in install_requires
BuildRequires:  texlive-latex
BuildRequires:  texlive-dvipng
%endif

# Optional but readme says they improve the graphs etc., so add them as weak
# dependencies
Recommends:     texlive-latex
Recommends:     texlive-dvipng

%description %_description

%prep
%forgeautosetup -S git

%generate_buildrequires
# the install requirements seem to be required for tests, so include them
%pyproject_buildrequires %{?with_tests:-r}

# correct import in test script
sed -i -e '/sys.path.append/ d' -e 's/import core./import pyplane.core./' tests/test_core.py

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files pyplane

install -p -m 0644 -Dt %{buildroot}/%{_metainfodir}/ %{SOURCE1}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE2}

%check
%if %{with tests}
%{pytest}
%endif

appstream-util validate-relax --nonet %{buildroot}/%{_metainfodir}/pyplane.metainfo.xml

%files -f %{pyproject_files}
%doc README.md AUTHORS
%{_bindir}/pyplane
%{_metainfodir}/pyplane.metainfo.xml
%{_datadir}/applications/pyplane.desktop

%changelog
%autochangelog