%bcond_without tests
# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We would like to generate PDF documentation as a substitute, but have not
# been able to successfully build the Sphinx-generated LaTeX for this
# particular package.
%bcond_with doc_pdf
# Until 2.0.0 final is released and packaged, this package uses (deprecated)
# traditional versioning with part of the upstream version information in the
# release field, instead of using tilde in the Version (e.g, 2.0.0~rc1).
#
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_prerelease_versions
# https://fedoraproject.org/wiki/Package_Versioning_Examples#Complex_versioning_examples
%global rc_number 18
%global forgeurl https://github.com/NiaOrg/NiaPy
%global tag %{version}rc%{rc_number}
Name: python-niapy
Version: 2.0.0
%forgemeta
Release: 0.3.rc%{rc_number}%{?dist}
Summary: Micro framework for building nature-inspired algorithms
License: MIT
URL: %{forgeurl}
Source0: %{forgesource}
# Exclude tests by patching setup.py rather than by removing in %%install,
# since the latter approach does not mix well with %%pyproject_save_files.
#
# To consider:
# - Should upstream do the same? This approach also affects the PyPI sdist.
# - Should we instead just package the tests as a separate subpackage, using
# %%exclude in the main package’s %%files section?
Patch0: 0001-Do-not-package-the-tests.patch
BuildArch: noarch
%global _description %{expand:
Nature-inspired algorithms are a very popular tool for solving optimization
problems. Numerous variants of nature-inspired algorithms have been developed
since the beginning of their era. To prove their versatility, those were tested
in various domains on various applications, especially when they are
hybridized, modified or adapted. However, implementation of nature-inspired
algorithms is sometimes a difficult, complex and tedious task. In order to
break this wall, NiaPy is intended for simple and quick use, without spending
time for implementing algorithms from scratch.}
%description %_description
%package -n python3-niapy
Summary: %{summary}
BuildRequires: python3-devel
%if %{with tests}
# setup.py: tests_require
#
# flake8 ~= 3.7.7
# astroid >= 2.0.4
# pytest ~= 3.7.1
# coverage ~= 4.4.2
# coverage-space ~= 1.0.2
#
# We do not run flake8:
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
# …nor do we care about test coverage. Furthermore, we must accept any newer
# version of pytest.
BuildRequires: python3dist(pytest) >= 3.7.1
%endif
%description -n python3-niapy %_description
%package doc
Summary: Documentation and examples for %{name}
%if %{with doc_pdf}
BuildRequires: make
BuildRequires: python3dist(sphinx)
BuildRequires: python3-sphinx-latex
BuildRequires: latexmk
BuildRequires: tex-xetex-bin
BuildRequires: /usr/bin/xindy
%endif
%description doc
%{summary}.
Full HTML documentation is available at
https://niapy.readthedocs.io/en/stable/index.html.
%prep
%forgeautosetup
# Since we aren’t building HTML documentation, we don’t need the HTML theme
# dependency:
sed -r -i 's/^(sphinx-.*theme)/#\1/' docs/requirements.txt
# Since pdflatex cannot handle Unicode inputs in general:
echo "latex_engine = 'xelatex'" >> docs/source/conf.py
# Avoid: ! LaTeX Error: Too deeply nested.
# Normally we could add a preamble like:
#
# cat >> docs/source/conf.py <<'EOF'
# latex_elements['preamble'] = r'''
# \usepackage{enumitem}
# \setlistdepth{99}
# '''
# EOF
#
# but that does not work well (“Undefined control sequence”).
#
# We can also try:
#
# echo "latex_elements['maxlistdepth'] = '10'" >> docs/source/conf.py
#
# but this produces errors like:
#
# ! LaTeX Error: \begin{list} on input line 21785 ended by \end{itemize}.
%generate_buildrequires
%pyproject_buildrequires -r %{?with_pdf_doc:docs/requirements.txt}
%build
%pyproject_wheel
%if %{with doc_pdf}
PYTHONPATH="${PWD}" %make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/build/latex LATEXMKOPTS='-quiet -f'
%endif
%install
%pyproject_install
%pyproject_save_files niapy
%check
%if %{with tests}
#k="${k-}${k+ and }not test_to_skip_sample1"
#k="${k-}${k+ and }not test_to_skip_sample2"
%pytest -ra -k "${k-}"
%endif
%files -n python3-niapy -f %{pyproject_files}
%doc README.rst README.md CHANGELOG.md Algorithms.md Problems.md
%files doc
%license LICENSE
%if %{with doc_pdf}
%doc docs/build/latex/NiaPy.pdf
%endif
%doc examples/
%doc paper/
%doc CONTRIBUTING.md CODE_OF_CONDUCT.md
%changelog
* Mon Nov 29 2021 Benjamin A. Beasley - 2.0.0-0.3rc18
- Port to pyproject-rpm-macros (“new guidelines”)
- Drop HTML documentation
- Stop skipping tests; they all pass now
* Wed Aug 18 2021 Iztok Fister Jr. - 2.0.0-0.1rc18
- Update to the latest upstream's release - rc18
* Fri Jul 23 2021 Fedora Release Engineering - 2.0.0-0.2rc17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Jun 11 2021 Iztok Fister Jr. - 2.0.0-0.1rc17
- Update to the latest upstream's release - rc17
- Remove patch
* Fri Jun 04 2021 Python Maint - 2.0.0-0.2rc16
- Rebuilt for Python 3.10
* Wed May 26 2021 Iztok Fister Jr. - 2.0.0-0.1rc16
- Update to the latest upstream's release - rc16
* Fri May 21 2021 Iztok Fister Jr. - 2.0.0-0.2rc15
- Add additional doc files found in repository to docs
* Sat May 15 2021 Iztok Fister Jr. - 2.0.0-0.1rc15
- Update to the latest upstream's release - rc15
* Fri Apr 23 2021 Iztok Fister Jr. - 2.0.0-0.2rc14
- Removing sed commands - dependencies already removed
- Added JOSS paper in documents
* Fri Apr 23 2021 Iztok Fister Jr. - 2.0.0-0.1rc14
- New version of package
* Thu Apr 15 2021 Iztok Fister Jr. - 2.0.0-0.5rc13
- Add examples in subpackage
* Tue Apr 6 2021 Iztok Fister Jr. - 2.0.0-0.4rc13
- Install additional docs
* Tue Mar 23 2021 Iztok Fister Jr. - 2.0.0-0.3rc13
- Skip one test (it is failing from time to time, because of random)
* Fri Mar 19 2021 Iztok Fister Jr. - 2.0.0-0.2rc13
- Remove dependency generator
- Conditional imports for tests
* Wed Mar 10 2021 Iztok Fister Jr. - 2.0.0-0.1rc13
- New version
* Thu Feb 11 2021 Iztok Fister Jr. - 2.0.0-0.5rc12
- Removing linter errors and typos
* Wed Jan 27 2021 Fedora Release Engineering - 2.0.0-0.4rc12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Fri Dec 4 2020 Iztok Fister Jr. - 2.0.0-0.3rc12
- New release - 2.0.0rc12
- Remove dependencies - xlwt, xlsxwriter
- New dependency - openpyxl
* Fri Nov 20 2020 Iztok Fister Jr. - 2.0.0-0.1rc11
- New release - 2.0.0rc11
* Wed Jul 29 2020 Fedora Release Engineering - 2.0.0-0.2rc10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Jul 02 2020 Ankur Sinha - 2.0.0-0.1rc10
- Remove dep on enum34
- Add python_provides for F32
* Sat Jun 27 2020 Ankur Sinha - 1.0.2-1
- Initial package