python-rpmautospec-core/python-rpmautospec-core.spec
Nils Philippsen fc3684e1c0 Update to 0.1.2
Signed-off-by: Nils Philippsen <nils@redhat.com>
2023-12-15 22:38:33 +01:00

103 lines
2.2 KiB
RPMSpec
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%bcond_with testcoverage
%if ! 0%{?rhel} || 0%{?rhel} >= 10
%bcond_without pyproject_build
%bcond_without genbrs
%else
%bcond_with pyproject_build
%bcond_with genbrs
%endif
%if 0%{undefined pyproject_files}
%global pyproject_files %{_builddir}/%{name}-%{version}-%{release}.%{_arch}-pyproject-files
%endif
%global srcname rpmautospec_core
%global canonicalname %{py_dist_name %{srcname}}
Name: python-%{canonicalname}
Version: 0.1.2
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 dont 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
%if %{without pyproject_build}
cat << SETUPPY > setup.py
from setuptools import setup
setup(name="%{canonicalname}", version="%{version}", packages=["%{srcname}"])
SETUPPY
%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
%autochangelog