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

%global pypi_name pyswarms
%global forgeurl https://github.com/ljvmiranda921/pyswarms

# Disable tests until upstream provides feedback
# https://github.com/ljvmiranda921/pyswarms/issues/516
%bcond_with tests

%global _description %{expand:
PySwarms is an extensible research toolkit for particle swarm 
optimization (PSO) in Python. It is intended for swarm 
intelligence researchers, practitioners, and students who prefer 
a high-level declarative interface for implementing PSO in their 
problems. PySwarms enables basic optimization with PSO and 
interaction with swarm optimizations.}

Name:           python-%{pypi_name}
Version:        1.3.0
Release:        %autorelease
Summary:        A Python-based Particle Swarm Optimization (PSO) library
%forgemeta
License:        MIT
URL:            %forgeurl
Source0:        %forgesource

# Fix compatibility with the newest sphinx stack
# already resolved in https://github.com/ljvmiranda921/pyswarms/pull/468
# remove patch when new version is released
Patch0:         Patch1.patch
# matplotlib 3.7 support
Patch1:         https://patch-diff.githubusercontent.com/raw/ljvmiranda921/pyswarms/pull/509.patch

BuildArch:      noarch

# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch: %{ix86}

BuildRequires:  python3-devel
BuildRequires:  git-core
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(nbsphinx)
BuildRequires:  python3-sphinx_rtd_theme


%description %_description

%package -n     python3-%{pypi_name}
Summary:        %{summary}

Requires:       python3dist(numpy) >= 1.10.4
Requires:       python3dist(scipy) >= 0.17

%description -n python3-%{pypi_name} %_description

%package -n python-%{pypi_name}-doc
Summary:        Documentation for PySwarms
%description -n python-%{pypi_name}-doc
Documentation for pyswarms package

%prep
%autosetup -n %{pypi_name}-%{version} -S git
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel
# generate html docs
PYTHONPATH=${PWD} sphinx-build-3 docs html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%install
%pyproject_install
%pyproject_save_files pyswarms

# Remove extra install files
rm -rf %{buildroot}/%{python3_sitelib}/tests

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

%files -n python3-%{pypi_name} -f %{pyproject_files}
%license LICENSE
%doc README.md

%files -n python-%{pypi_name}-doc
%doc html
%doc AUTHORS.rst HISTORY.rst
%license LICENSE

%changelog
* Wed Sep 06 2023 Sandro <devel@penguinpee.nl> - 1.3.0-20
- Disable tests until upstream provides feedback
- Use forge macros
- Use Python RPM macros
- Clean up BRs (now autogenerated by macros)
- Close RHBZ#2210608 RHBZ#2226302 and RHBZ#2220454

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jul 03 2023 Python Maint <python-maint@redhat.com> - 1.3.0-15
- Rebuilt for Python 3.12

* Sun Jun 25 2023 Orion Poplawski <orion@nwra.com> - 1.3.0-14
- Add upstream patch for matplotlib 3.7 support

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Mon Dec 19 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 1.3.0-12
- Drop support for i686

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

* Wed Jun 15 2022 Python Maint <python-maint@redhat.com> - 1.3.0-10
- Rebuilt for Python 3.11

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

* Sun Nov 7 2021 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 1.3.0-8
- Source correction

* Mon Nov 1 2021 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 1.3.0-7
- Remove dependency

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

* Wed Jul 7 2021 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 1.3.0-5
- New patch for compatibility with the new sphinx stack

* Tue Jul 6 2021 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 1.3.0-4
- Use pytest macro

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

* Sun May 2 2021 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 1.3.0-2
- Add additional docs

* Sat Mar 20 2021 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 1.3.0-1
- Initial package