Convert to pyproject-rpm-macros

This commit is contained in:
Miro Hrončok 2020-10-02 12:24:34 +02:00
parent b03bc8ec55
commit 7c53583d11

View File

@ -6,8 +6,6 @@
# Specify --without tests to prevent the dependency loop on python-pytest # Specify --without tests to prevent the dependency loop on python-pytest
%bcond_without tests %bcond_without tests
%global python_wheelname %{pypi_name}-%{version}-py2.py3-none-any.whl
Name: python-%{pypi_name} Name: python-%{pypi_name}
Version: 20.4 Version: 20.4
Release: 3%{?dist} Release: 3%{?dist}
@ -21,31 +19,44 @@ BuildArch: noarch
# Remove dependency on six to make package lighter, backported from upstream # Remove dependency on six to make package lighter, backported from upstream
Patch1: %{url}/commit/39a70cce.patch Patch1: %{url}/commit/39a70cce.patch
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-pyparsing BuildRequires: pyproject-rpm-macros
%if %{with tests}
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pretend
%endif
%if %{with docs}
BuildRequires: python%{python3_pkgversion}-sphinx
%endif
# We specify dependencies to build the wheel manually to avoid circular
# dependency on self.
# We also don't use the python3dist() form, in case packaging is ever used
# in the provides generator.
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-pip BuildRequires: python%{python3_pkgversion}-pip
BuildRequires: python%{python3_pkgversion}-wheel BuildRequires: python%{python3_pkgversion}-wheel
%description # Upstream uses nox for testing, we specify the test deps manually as well.
%if %{with tests}
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pretend
BuildRequires: python%{python3_pkgversion}-pyparsing
%endif
%if %{with docs}
BuildRequires: python%{python3_pkgversion}-sphinx
BuildRequires: python%{python3_pkgversion}-pyparsing
%endif
%global _description %{expand:
python-packaging provides core utilities for Python packages like utilities for python-packaging provides core utilities for Python packages like utilities for
dealing with versions, specifiers, markers etc. dealing with versions, specifiers, markers etc.}
%description %_description
%package -n python%{python3_pkgversion}-%{pypi_name} %package -n python%{python3_pkgversion}-%{pypi_name}
Summary: %{summary} Summary: %{summary}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}}
%description -n python%{python3_pkgversion}-%{pypi_name} # This is kept for compatibility with Fedora < 33 only:
python3-packaging provides core utilities for Python packages like utilities for %py_provides python%{python3_pkgversion}-%{pypi_name}
dealing with versions, specifiers, markers etc.
%description -n python%{python3_pkgversion}-%{pypi_name} %_description
%if %{with docs} %if %{with docs}
%package -n python-%{pypi_name}-doc %package -n python-%{pypi_name}-doc
@ -55,13 +66,13 @@ Summary: python-packaging documentation
Documentation for python-packaging Documentation for python-packaging
%endif %endif
%prep %prep
%autosetup -p1 -n %{pypi_name}-%{version} %autosetup -p1 -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%build %build
%py3_build_wheel %pyproject_wheel
%if %{with docs} %if %{with docs}
# generate html docs # generate html docs
@ -72,19 +83,22 @@ rm -rf html/.{doctrees,buildinfo}
rm -rf html/_static/fonts/ rm -rf html/_static/fonts/
%endif %endif
%install %install
%py3_install_wheel %{python_wheelname} %pyproject_install
%pyproject_save_files %{pypi_name}
%if %{with tests} %if %{with tests}
%check %check
%pytest %pytest
%endif %endif
%files -n python%{python3_pkgversion}-%{pypi_name}
%files -n python%{python3_pkgversion}-%{pypi_name} -f %{pyproject_files}
%license LICENSE LICENSE.APACHE LICENSE.BSD %license LICENSE LICENSE.APACHE LICENSE.BSD
%doc README.rst CHANGELOG.rst CONTRIBUTING.rst %doc README.rst CHANGELOG.rst CONTRIBUTING.rst
%{python3_sitelib}/%{pypi_name}/
%{python3_sitelib}/%{pypi_name}-*-info/
%if %{with docs} %if %{with docs}
%files -n python-%{pypi_name}-doc %files -n python-%{pypi_name}-doc
@ -92,6 +106,7 @@ rm -rf html/_static/fonts/
%license LICENSE LICENSE.APACHE LICENSE.BSD %license LICENSE LICENSE.APACHE LICENSE.BSD
%endif %endif
%changelog %changelog
* Fri Oct 02 2020 Miro Hrončok <mhroncok@redhat.com> - 20.4-3 * Fri Oct 02 2020 Miro Hrončok <mhroncok@redhat.com> - 20.4-3
- Drop the dependency on six to make the package lighter - Drop the dependency on six to make the package lighter