## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 6;
    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 pypi_name scikit-misc
%global archive_name scikit_misc
%global module_name skmisc

# Enable tests
%bcond_without tests

%global _description %{expand:
Miscellaneous tools for data analysis and scientific computing.}

Name:           python-%{pypi_name}
Version:        0.2.0
Release:        %autorelease
Summary:        Miscellaneous tools for data analysis and scientific computing

# MIT License applies to doc/theme/static/bootstrap-3.4.1
# Python-2.0.1 license applies to doc/_static/copybutton.js
License:        BSD-3-Clause AND MIT AND Python-2.0.1
URL:            https://github.com/has2k1/scikit-misc
Source0:        %{pypi_source %{archive_name}}
# Add meson build options to pyproject.toml
# Passing this through one of the macros appears unsupported
Patch0:         use_flexiblas.patch

%description %_description

%package -n python3-%{pypi_name}
Summary:        %{summary}
BuildRequires:  python3-devel
BuildRequires:  git-core
# For optimized performance
BuildRequires:  flexiblas-devel
BuildRequires:  gcc, gcc-gfortran
BuildRequires:  cmake
BuildRequires:  patchelf
%if %{with tests}
BuildRequires:  python3-pytest
%endif


%description -n python3-%{pypi_name} %_description


%prep
%autosetup -p1 -n %{archive_name}-%{version} -S git

%py3_shebang_fix spin skmisc/_build_utils/

# Disable coverage
sed -i -e 's/--cov=skmisc --cov-report=xml//' pyproject.toml

# Do not attempt to build with an old version of numpy; this makes 
# sense for PyPI distribution (oldest-supported-numpy) but not here.
sed -r -i 's/(numpy)==/\1>=/' pyproject.toml


%generate_buildrequires
%pyproject_buildrequires -w


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files %{module_name}


%check
%if %{with tests}
  %pytest
%else
  %pyproject_check_import
%endif


%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst
%license LICENSE

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

* Thu Jun 15 2023 Python Maint <python-maint@redhat.com> - 0.2.0-5
- Rebuilt for Python 3.12

* Sun Apr 30 2023 Sandro <devel@penguinpee.nl> - 0.2.0-4
- Use mesonpy for building

* Sat Apr 29 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.2.0-3
- Remove unversioned “python” BR
- Fix shebang

* Tue Apr 18 2023 Sandro <devel@penguinpee.nl> - 0.2.0-2
- Enable tests again
- Needs to be run with pytest not meson

* Sun Apr 16 2023 Sandro <devel@penguinpee.nl> - 0.2.0-1
- Update to 0.2.0
- Switch to Meson build system
- Use PyPI source
- Drop patch and associated BR (fixed upstream)

* Tue Feb 07 2023 Miro Hrončok <miro@hroncok.cz> - 0.1.4-5
- Drop a patch, %%pyproject_buildrequires is fixed

* Tue Feb 07 2023 Miro Hrončok <miro@hroncok.cz> - 0.1.4-4
- Fix wrong conversion to %%autochangelog

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

* Fri Oct 21 2022 Sandro <devel@penguinpee.nl> - 0.1.4-2
- Add patch to dist-git

* Fri Oct 21 2022 Sandro <devel@penguinpee.nl> - 0.1.4-1
- Initial release (RHBZ#2133438)