## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 6;
    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

# Require network, so run locally on mock with --enable-network
%bcond_with tests

%global _description \
A LEMS (http://lems.github.io/LEMS) simulator written in Python which can be \
used to run NeuroML2 (http://neuroml.org/neuroml2.php) models.


Name:           python-PyLEMS
Version:        0.5.9
Release:        %autorelease
Summary:        LEMS interpreter implemented in Python

License:        LGPLv3

# Use github source. Pypi source does not include license and examples.
URL:            https://github.com/LEMS/pylems/
Source0:        %{url}/archive/v%{version}/pylems-%{version}.tar.gz
# Generate man page for pylems
# help2man -n "LEMS interpreter implemented in Python" --version-string="0.5.9" -N pylems -S "https://lems.github.io" -o pylems.1
# Sent upstream: https://github.com/LEMS/pylems/pull/64

BuildArch:      noarch

%description
%{_description}

%package -n python3-PyLEMS
Summary:        %{summary}
BuildRequires:  python3-devel
%if %{with tests}
BuildRequires:  %{py3_dist pytest}
%endif

%description -n python3-PyLEMS
%{_description}

%package doc
Summary: %{summary}

%description doc
%{_description}


%prep
%autosetup -n pylems-%{version}

# correct man-page path
sed -i 's|\[("man/man1"|\[("share/man/man1"|' setup.py

# remove shebang
sed -i '1d' lems/dlems/exportdlems.py

%generate_buildrequires
%pyproject_buildrequires %{?with_tests: -r}

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files lems


%check
%if %{with tests}
# A lot of the tests use files from other software repositories, so we can't use them.
%{pytest}
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} examples/apitest.py
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} examples/apitest2.py
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} examples/loadtest.py
%endif

%files -n python3-PyLEMS -f %{pyproject_files}
%{_bindir}/pylems
%{_mandir}/man1/pylems.1*

%files doc
%license LICENSE.lesser
%doc README.md examples

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

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

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> 0.5.9-4
- Rebuilt for Python 3.11

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 0.5.9-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Mon Dec 27 2021 Vanessa_kris <vanessaigwe1@gmail.com> 0.5.9-2
- modified man-page path

* Sat Dec 25 2021 Vanessa_kris <vanessaigwe1@gmail.com> 0.5.9-1
- update to latest release

* Mon Nov 01 2021 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.5.8-1
- feat: update to 0.5.8
- Also adds a man page (also sent upstream)

* Sat Aug 07 2021 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.5.4-1
- feat: update to 0.5.4

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> 0.5.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> 0.5.2-2
- Rebuilt for Python 3.10

* Thu Feb 18 2021 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.5.2-1
- Update to latest release

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> 0.5.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Tue Oct 27 2020 Tomas Hrnciar <thrnciar@redhat.com> 0.5.1-2
- Replace Python version glob with macro (needed for Python 3.10+)

* Fri Sep 04 2020 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.5.1-1
- Update to 0.5.1

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> 0.5.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu Jun 25 2020 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.5.0-3
- Explicitly BR setuptools

* Tue May 26 2020 Miro Hrončok <miro@hroncok.cz> 0.5.0-2
- Rebuilt for Python 3.9

* Wed Apr 22 2020 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.5.0-1
- Update to 0.5.0

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> 0.4.9.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Oct 03 2019 Miro Hrončok <miro@hroncok.cz> 0.4.9.1-5
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Mon Aug 19 2019 Miro Hrončok <miro@hroncok.cz> 0.4.9.1-4
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> 0.4.9.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> 0.4.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Thu Nov 01 2018 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.4.9.1-1
- Initial scm import