## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 4;
    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 desc %{expand: \
Opytimizer is a Python library consisting of
meta-heuristic optimization algorithms}

%bcond_without docs

%bcond_without tests

%global forgeurl https://github.com/gugarosa/opytimizer

Name:           python-opytimizer
Version:        3.1.2
Release:        %autorelease
Summary:        Python implementation of metaheuristic optimization algorithms

%forgemeta

License:        Apache-2.0
URL:            https://github.com/gugarosa/opytimizer
Source0:        %forgesource

BuildArch:      noarch

# Fix import when building docs
# PR: https://github.com/gugarosa/opytimizer/pull/33
Patch:          33.patch

# Move development dependencies out from the main dependencies
# PR: https://github.com/gugarosa/opytimizer/pull/34
Patch:          34.patch

%description
%{desc}

%package -n python3-opytimizer
Summary:        %{summary}
BuildRequires:      python3-devel

%if %{with tests}
BuildRequires:      %{py3_dist pytest}

# for several X11 tests
BuildRequires:  xorg-x11-server-Xvfb

%endif

# sphinx-autoapi is missing
%if %{with docs}
BuildRequires:  make
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
BuildRequires:  %{py3_dist sphinx}
BuildRequires:  %{py3_dist sphinx-rtd-theme}
%endif

%description -n python3-opytimizer
%{desc}

%if %{with docs}
%package doc
BuildArch:      noarch
Summary:        %{summary}

%description doc
Documentation for %{name}.
%endif

%prep
%forgeautosetup -p1

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%if %{with docs}
%make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif

%install
%pyproject_install
%pyproject_save_files opytimizer

%check

# despite the use of xvfb, several plots are shown
%if %{with tests}
xvfb-run -a %{python3} -m pytest -k 'not plot'
%endif

%files -n python3-opytimizer -f %{pyproject_files}
%doc README.md

%if %{with docs}
%files doc
%license LICENSE
%doc CODE_OF_CONDUCT.md
%doc docs/_build/latex/opytimizer.pdf
%endif

%changelog
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jul 10 2023 Python Maint <python-maint@redhat.com> - 3.1.2-3
- Rebuilt for Python 3.12

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

* Fri Jan 13 2023 Iztok Fister Jr <iztok@iztok-jr-fister.eu> - 3.1.2-1
- Initial import (fedora#2150221)