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

Name:       python-neatdend
Version:    0.9.2
Release:    %autorelease
Summary:    NEAT (NEural Analysis Toolkit)

# Automatically converted from old format: GPLv3 - review is highly recommended.
License:    GPL-3.0-only
URL:        https://github.com/unibe-cns/NEAT
Source0:    %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
# Patches: https://github.com/sanjayankur31/NEAT/tree/fedora-v0.9.2
# Support all arches for Neuron libs
# issue filed: https://github.com/unibe-cns/NEAT/issues/142
Patch0:     0001-feat-support-all-arches.patch
Patch1:	    https://github.com/unibe-cns/NEAT/commit/504b39822b9913e5a8c6aff65df840cc2e31167d.patch	    
# Fix compatibility with recent Matplotlib
Patch2:     https://github.com/unibe-cns/NEAT/commit/8eb1f4be85da0c8fdbcbac627c5198a67e29b22c.patch

BuildRequires:  python3-devel
BuildRequires:  python3-pytest
BuildRequires:  gcc gcc-c++
BuildRequires:  git-core
BuildRequires:  python3-neuron
BuildRequires:  neuron-devel

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

%global _description %{expand:
NEAT is a python library for the study,
simulation and simplification of morphological neuron models.}

%description %_description

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

%description -n python3-neatdend %_description


%prep
%autosetup -n NEAT-%{version} -S git

sed -i 's/^numpy~=1.20.2/numpy>=1.20.2/' requirements/requirements.txt
sed -i 's/^matplotlib~=3.4.1/matplotlib>=3.4.1/' requirements/requirements.txt
sed -i 's/^pytest~=5.3.2/pytest>=5.3.2/' requirements/requirements.txt
sed -i 's/^scikit_learn~=0.24.2/scikit_learn>=0.24.2/' requirements/requirements.txt
sed -i 's/^scipy~=1.6.3/scipy>=1.6.3/' requirements/requirements.txt
sed -i 's/^sympy~=1.7.1/sympy>=1.7.1/' requirements/requirements.txt
sed -i 's/^cython~=0.29.4/cython>=3.0.0/' requirements/requirements.txt

# Ad hoc patch for NumPy 2.x
# Upstream is working on 1.0.0, which will be compatible.
sed -i 's/np\.NaN/np.nan/g' $(grep -rl 'np\.NaN')
sed -i 's/np\.infty/np.inf/g' $(grep -rl 'np\.infty')
sed -i 's/np\.product/np.prod/g' $(grep -rl 'np\.product')

%generate_buildrequires
%pyproject_buildrequires -r


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files -l neat

%check
# a few tests fail on i686.
# Upstream report: https://github.com/unibe-cns/NEAT/issues/142#issuecomment-1107874903
%ifnarch %{ix86}
# we need to run these in a different directory to ensure that the module isn't
# imported from the source directory
mkdir testdir && pushd testdir
# Python path must be defined so that compilechannels uses the installed module
PYTHONPATH=$RPM_BUILD_ROOT/%{python3_sitelib}:$RPM_BUILD_ROOT/%{python3_sitearch} $RPM_BUILD_ROOT/%{_bindir}/compilechannels default
%pytest ../
popd
%endif

# remove files generated for the tests
rm -rf find $RPM_BUILD_ROOT/%{python3_sitearch}/neat/tools/simtools/neuron/mech/*.mod
rm -rf find $RPM_BUILD_ROOT/%{python3_sitearch}/neat/tools/simtools/neuron/%{_arch}

%files -n python3-neatdend -f %{pyproject_files}
%doc README.rst CODE_OF_CONDUCT.rst CONTRIBUTING.rst CONTRIBUTORS.rst
%{_bindir}/compilechannels

%changelog
## START: Generated by rpmautospec
* Fri Dec 20 2024 Sandro <devel@penguinpee.nl> - 0.9.2-21
- Ad hoc patch for NumPy 2.x

* Mon Jul 29 2024 Miroslav Suchý <msuchy@redhat.com> - 0.9.2-20
- convert GPLv3 license to SPDX

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.2-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Mon Jun 10 2024 Python Maint <python-maint@redhat.com> - 0.9.2-18
- Rebuilt for Python 3.13

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.2-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.2-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Wed Jan 03 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.9.2-15
- Assert that the .dist-info directory contains a license file

* Thu Sep 07 2023 Sandro <devel@penguinpee.nl> - 0.9.2-14
- Fix version pinning for Cython
- Make Koji happy fixing requirements s/~=/>=/
- Close RHBZ#2226254

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

* Tue Jul 04 2023 Python Maint <python-maint@redhat.com> - 0.9.2-12
- Rebuilt for Python 3.12

* Fri Feb 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.9.2-11
- Leaf package on ix86: drop ix86 support

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

* Sat Oct 29 2022 Sandro <devel@penguinpee.nl> - 0.9.2-9
- Rebuild for FTBFS (RHBZ#2129862)

* Sat Aug 20 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.9.2-8
- Fix compatibility with Matplotlib 3.6.0

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

* Fri Jul 08 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.9.2-6
- delted *src.rpm

* Fri Jul 08 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.9.2-5
- Added 504b39822b9913e5a8c6aff65df840cc2e31167d.patch

* Thu Jul 07 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.9.2-4
- initial import to src.fp.o

* Thu Jul 07 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.9.2-3
- Revert "build fails"

* Thu Jul 07 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.9.2-2
- build fails

* Thu Jul 07 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.9.2-1
- updated spec file
## END: Generated by rpmautospec