Blob Blame History Raw
# Building of HTML docs fails in Python 3.12
# Disable as a temporary measure
%bcond_without docs

Name:           python-deap
Version:        1.4.1

Release:        %autorelease
Summary:        Distributed Evolutionary Algorithms in Python

License:        LGPL-3.0-only

Patch:          0001-Use-float-instead-of-np.float.patch
Patch:          0002-setup-fix-git-invocation-for-exlinks-add-override.patch
Patch:          0001-Fix-use-of-unknown-escape-seqeuences.patch

BuildRequires:  gcc
BuildRequires:  gcc-c++

BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-pypandoc
BuildRequires:  python3-pytest
BuildRequires:  python3-nose
BuildRequires:  python3-numpy

# documentation
%if %{with docs}
BuildRequires:  python3-sphinx
BuildRequires:  texlive-scheme-basic
BuildRequires:  tex(ucs.sty)
BuildRequires:  tex(anyfontsize.sty)
BuildRequires:  python3-numpy
BuildRequires:  python3-matplotlib

%global _description %{expand:
DEAP is a novel evolutionary computation framework for rapid prototyping and
testing of ideas that implements a number of genetic optimization algorithms
behind a common interface.}

%description %_description

%package -n     python3-deap
Requires:       python3-numpy
BuildRequires:  python3-nose
Summary:        %{summary}
%{?python_provide:%python_provide python3-deap}

%description -n python3-deap %_description

%if %{with docs}
%package -n python-deap-doc
Summary:        Documentation for deap
BuildArch:      noarch
%description -n python-deap-doc

%autosetup -n deap-%{version} -p1
sed -i 's/\["git", "rev-parse", "HEAD"\]/["echo", "deap-%{version}-%{release}"]/' \

%if %{with docs}
sed -i -r "s|'matplotlib.sphinxext.only_directives',||" doc/


# generate html docs
%if %{with docs}
GITHUB_COMMIT=%{version} \
  PYTHONPATH=build/lib.%{python3_platform}-%{python3_version} \
  sphinx-build-3 doc build/html

# remove the sphinx-build leftovers
rm -rf build/html/.{doctrees,buildinfo}

%global _docdir_fmt %{name}


  # Fails with: AssertionError: CMA algorithm did not converged properly.

%pytest tests/
PYTHONPATH=%{buildroot}%{python3_sitearch} pytest -v "${OPTIONS[@]}"

%files -n python3-deap
%license LICENSE.txt

%if %{with docs}
%files -n python-deap-doc
%license LICENSE.txt
%doc build/html