## START: Set by rpmautospec
## (rpmautospec version 0.3.1)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    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 _description %{expand:
NeuroM is a Python-based toolkit for the analysis and processing of neuron
morphologies.

Documentation is available at https://neurom.readthedocs.io/
}
%global forgeurl    https://github.com/BlueBrain/NeuroM

Name:           python-neurom
Version:        3.2.2
Release:        %autorelease
Summary:        Neuronal Morphology Analysis Tool

%global tag  v%{version}
%forgemeta

License:        BSD
URL:            %forgeurl
Source0:        %forgesource

BuildArch:      noarch

%description %_description

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

%description -n python3-neurom %_description

%package doc
Summary:        Documentation for %{name}

%description doc %_description

%prep
%forgesetup

# Fix shebangs
find . -type f -exec sed -i 's|^#![  ]*/usr/bin/env.*$|#!/usr/bin/python3|' {} ';'
sed -i '/^#![  ]*\/usr\/bin\/python3.*$/ d' neurom/check/runner.py

# correct config files path
# not sure why this was changed: https://github.com/BlueBrain/NeuroM/commit/dbc3bd069a6fbded6c4a64cc038adb37c0b06932
sed -i 's|graft neurom/config|graft neurom/apps/config|' MANIFEST.in

%generate_buildrequires
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
%pyproject_buildrequires -t

%build
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
%pyproject_wheel

%install
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
%pyproject_install
%pyproject_save_files neurom

# Remove spurious installed files
rm -rf $RPM_BUILD_ROOT/%{python3_sitelib}/tests/

%check
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
# tests failing
# reported upstream: https://github.com/BlueBrain/NeuroM/issues/983
%pytest -k "not test_morph_stat and not test_morph_check and not test_extract_stats_scalar_feature and not test_single_neurite_no_soma and not test_skip_header and not test_markers"

%files -n python3-neurom -f %{pyproject_files}
%doc README.md AUTHORS.md
%{_bindir}/neurom

%files doc
%license LICENSE.txt
%doc examples tutorial

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

* Sun Oct 09 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 3.2.2-1
- feat: update to 3.2.2 (fixes rh#2082562)

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

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

* Thu Mar 03 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 3.1.0-3
- fix: patch manifest to include default config file

* Thu Mar 03 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 3.1.0-2
- fix: install config files dir

* Sun Feb 20 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 3.1.0-1
- feat: update to 3.1.0 (fixes rhbz#1952492)

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

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

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

* Wed Apr 14 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.8.0-1
- Initial build