Add new bootstrapping bcond

The Python RPM dependency generators now require python3-packaging.

In order to bootstrap a new Python version, we need to build this without the
generators first. The provides and requires are added manually in that case.

At that point, we cannot build the docs or run the tests either,
so the bootstrap bcond also disables docs and tests.
This commit is contained in:
Miro Hrončok 2021-02-24 17:10:39 +01:00
parent 25f529f4bc
commit 704f208529

View File

@ -1,10 +1,20 @@
%global pypi_name packaging %global pypi_name packaging
# Specify --with bootstrap to build in bootstrap mode
# This mode is needed, because python3-rpm-generators need packaging
# When bootstrapping, disable tests and docs as well.
%bcond_with bootstrap
%if %{without bootstrap}
# Specify --without docs to prevent the dependency loop on python-sphinx # Specify --without docs to prevent the dependency loop on python-sphinx
%bcond_without docs %bcond_without docs
# 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
%else
%bcond_with docs
%bcond_with tests
%endif
Name: python-%{pypi_name} Name: python-%{pypi_name}
Version: 20.9 Version: 20.9
@ -19,23 +29,17 @@ BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: pyproject-rpm-macros BuildRequires: pyproject-rpm-macros
# We specify dependencies to build the wheel manually to avoid circular %if %{with bootstrap}
# 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}-setuptools
BuildRequires: python%{python3_pkgversion}-pip %endif
BuildRequires: python%{python3_pkgversion}-wheel
# Upstream uses nox for testing, we specify the test deps manually as well. # Upstream uses nox for testing, we specify the test deps manually as well.
%if %{with tests} %if %{with tests}
BuildRequires: python%{python3_pkgversion}-pytest BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pretend BuildRequires: python%{python3_pkgversion}-pretend
BuildRequires: python%{python3_pkgversion}-pyparsing
%endif %endif
%if %{with docs} %if %{with docs}
BuildRequires: python%{python3_pkgversion}-sphinx BuildRequires: python%{python3_pkgversion}-sphinx
BuildRequires: python%{python3_pkgversion}-pyparsing
%endif %endif
@ -52,6 +56,12 @@ Summary: %{summary}
# This is kept for compatibility with Fedora < 33 only: # This is kept for compatibility with Fedora < 33 only:
%py_provides python%{python3_pkgversion}-%{pypi_name} %py_provides python%{python3_pkgversion}-%{pypi_name}
%if %{with bootstrap}
Provides: python%{python3_pkgversion}dist(packaging) = %{version}
Provides: python%{python3_version}dist(packaging) = %{version}
Requires: python%{python3_version}dist(pyparsing)
%endif
%description -n python%{python3_pkgversion}-%{pypi_name} %_description %description -n python%{python3_pkgversion}-%{pypi_name} %_description
@ -71,8 +81,18 @@ Documentation for python-packaging
# furo is not available in Fedora # furo is not available in Fedora
sed -i '/html_theme = "furo"/d' docs/conf.py sed -i '/html_theme = "furo"/d' docs/conf.py
%if %{without bootstrap}
%generate_buildrequires
%pyproject_buildrequires -r
%endif
%build %build
%if %{with bootstrap}
%py3_build
%else
%pyproject_wheel %pyproject_wheel
%endif
%if %{with docs} %if %{with docs}
# generate html docs # generate html docs
@ -85,8 +105,13 @@ rm -rf html/_static/fonts/
%install %install
%if %{with bootstrap}
%py3_install
echo '%{python3_sitelib}/packaging*' > %{pyproject_files}
%else
%pyproject_install %pyproject_install
%pyproject_save_files %{pypi_name} %pyproject_save_files %{pypi_name}
%endif
%if %{with tests} %if %{with tests}