## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 7;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%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.1
Summary:        Phase plane analysis of nonlinear systems

%global  tag PyPlane_v%{version}
%forgemeta

Release:        %autorelease
License:        GPLv3
URL:            %{forgeurl}
Source0:        %{forgesource}

BuildArch:      noarch

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

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

# Add virtual provides to help users find it
Provides:       python3-pyplane

%description %_description

%prep
%forgesetup

%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

desktop-file-install --dir=%{buildroot}%{_datadir}/applications packaging/linux/pyplane.desktop
desktop-file-validate %{buildroot}%{_datadir}/applications/pyplane.desktop


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


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


%changelog
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> 2.0.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> 2.0.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Fri Jun 17 2022 Python Maint <python-maint@redhat.com> 2.0.1-5
- Rebuilt for Python 3.11

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.1-4
- fix: correct forgemeta usage

* Wed Feb 02 2022 Shane Allcroft <shaneallcroft@gmail.com> 2.0.1-3
- remove accidental additions

* Wed Feb 02 2022 Shane Allcroft <shaneallcroft@gmail.com> 2.0.1-1
- updating .spec file to version reviewed at
  https://bugzilla.redhat.com/show_bug.cgi?id=2008153

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.0-8
- feat: add missing requires

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.0-7
- feat: add patch to log to XDG_DATA_DIR

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.0-6
- feat: remove virtual provides, not needed

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.0-5
- feat: install appdata and desktop file

* Wed Feb 02 2022 Shane Allcroft <shaneallcroft@gmail.com> 2.0.0-4
- updates, files now same as upstream PR

* Wed Feb 02 2022 Shane Allcroft <shaneallcroft@gmail.com> 2.0.0-3
- added desktop file and metainfo file

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.0-2
- fix: correct test script

* Wed Feb 02 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 2.0.0-1
- feat: rename to pyplane