## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## 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

%bcond_with testcoverage

# Only generate buildrequires or use PEP 518 style building on Fedora and new EPEL releases because
# Poetry is missing elsewhere. Fall back to using setuptools instead.
%if ! 0%{?rhel} || 0%{?epel} >= 10
%bcond_without genbrs
%bcond_without pyproject_build
%else
%bcond_with genbrs
%bcond_with pyproject_build
%endif

%if 0%{undefined pyproject_files}
%global pyproject_files %{_builddir}/%{name}-%{version}-%{release}.%{_arch}-pyproject-files
%endif

%global srcname rpmautospec_core
%global canonicalname rpmautospec-core

Name: python-%{canonicalname}
Version: 0.1.5
Release: %autorelease
Summary: Minimum functionality for rpmautospec

License: MIT
URL: https://github.com/fedora-infra/%{canonicalname}
Source0: %{pypi_source %{srcname}}
BuildArch: noarch
BuildRequires: python3-devel >= 3.6.0
# The dependencies needed for testing don’t get auto-generated.
BuildRequires: python3dist(pytest)
%if %{with testcoverage}
BuildRequires: python3dist(pytest-cov)
%endif
BuildRequires: sed

%if %{with genbrs}
%generate_buildrequires
%{pyproject_buildrequires}
%else
BuildRequires: python3dist(pip)
BuildRequires: python3dist(setuptools)
%endif

%global _description %{expand:
This package contains minimum functionality to determine if an RPM spec file
uses rpmautospec features.}

%description %_description

%package -n python3-%{canonicalname}
Summary: %{summary}
%if %{without pyproject_build}
%py_provides python3-%{canonicalname}
%endif

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

%prep
%autosetup -n %{srcname}-%{version}

%if %{without testcoverage}
cat << PYTESTINI > pytest.ini
[pytest]
addopts =
PYTESTINI
%endif

%build
%if %{with pyproject_build}
%pyproject_wheel
%else
%py3_build
%endif

%install
%if %{with pyproject_build}
%pyproject_install
%pyproject_save_files %{srcname}
# Work around poetry not listing license files as such in package metadata.
sed -i -e 's|^\(.*/LICENSE\)|%%license \1|g' %{pyproject_files}
%else
%py3_install
echo '%{python3_sitelib}/%{srcname}*' > %{pyproject_files}
%endif

%check
%pytest

%files -n python3-%{canonicalname} -f %{pyproject_files}
%doc README.md
%if %{without pyproject_build}
%license LICENSE
%endif

%changelog
## START: Generated by rpmautospec
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Thu Jun 27 2024 Nils Philippsen <nils@redhat.com> - 0.1.5-1
- Update to 0.1.5

* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 0.1.4-5
- Rebuilt for Python 3.13

* Mon Feb 12 2024 Nils Philippsen <nils@redhat.com> - 0.1.4-4
- Cope with undefined %%py_dist_name

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

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

* Tue Jan 09 2024 Nils Philippsen <nils@redhat.com> - 0.1.4-1
- Update to 0.1.4

* Fri Jan 05 2024 Nils Philippsen <nils@redhat.com> - 0.1.3-1
- Update to 0.1.3

* Fri Dec 15 2023 Nils Philippsen <nils@redhat.com> - 0.1.2-1
- Update to 0.1.2

* Sun Dec 03 2023 Yaakov Selkowitz <yselkowi@redhat.com> - 0.1.1-8
- Always disable test coverage checks

* Fri Nov 17 2023 Nils Philippsen <nils@redhat.com> - 0.1.1-6
- Don’t generate build requires on EL <= 9

* Fri Nov 17 2023 Nils Philippsen <nils@redhat.com> - 0.1.1-5
- Build using setuptools on EL <= 9

* Fri Nov 17 2023 Nils Philippsen <nils@redhat.com> - 0.1.1-2
- Make it build on older EL releases

* Wed Nov 15 2023 Nils Philippsen <nils@redhat.com> - 0.1.1-1
- Update to 0.1.1

* Tue Nov 14 2023 Nils Philippsen <nils@redhat.com> - 0.1.0-1
- Initial import
## END: Generated by rpmautospec