diff --git a/_multibuild b/_multibuild
index fcc7b97..d0dc7ba 100644
--- a/_multibuild
+++ b/_multibuild
@@ -1,3 +1,4 @@
test
+ primary
diff --git a/no-legacyversion-warning.patch b/no-legacyversion-warning.patch
deleted file mode 100644
index 709c384..0000000
--- a/no-legacyversion-warning.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-Index: packaging-21.2/packaging/specifiers.py
-===================================================================
---- packaging-21.2.orig/packaging/specifiers.py
-+++ packaging-21.2/packaging/specifiers.py
-@@ -270,12 +270,6 @@ class LegacySpecifier(_IndividualSpecifi
- def __init__(self, spec: str = "", prereleases: Optional[bool] = None) -> None:
- super().__init__(spec, prereleases)
-
-- warnings.warn(
-- "Creating a LegacyVersion has been deprecated and will be "
-- "removed in the next major release",
-- DeprecationWarning,
-- )
--
- def _coerce_version(self, version: UnparsedVersion) -> LegacyVersion:
- if not isinstance(version, LegacyVersion):
- version = LegacyVersion(str(version))
-Index: packaging-21.2/packaging/version.py
-===================================================================
---- packaging-21.2.orig/packaging/version.py
-+++ packaging-21.2/packaging/version.py
-@@ -108,12 +108,6 @@ class LegacyVersion(_BaseVersion):
- self._version = str(version)
- self._key = _legacy_cmpkey(self._version)
-
-- warnings.warn(
-- "Creating a LegacyVersion has been deprecated and will be "
-- "removed in the next major release",
-- DeprecationWarning,
-- )
--
- def __str__(self) -> str:
- return self._version
-
diff --git a/python-packaging.changes b/python-packaging.changes
index 6219fbc..1c8ba72 100644
--- a/python-packaging.changes
+++ b/python-packaging.changes
@@ -1,3 +1,32 @@
+-------------------------------------------------------------------
+Mon Aug 1 07:44:59 UTC 2022 - Ben Greiner
+
+- BuildIgnore python3-packaging for primary bootstrap.
+
+-------------------------------------------------------------------
+Thu Jul 21 11:16:04 UTC 2022 - Ben Greiner
+
+- Refine build and runtime requirements for primary and non-primary
+ builds
+
+-------------------------------------------------------------------
+Fri Jul 15 12:30:44 UTC 2022 - Ben Greiner
+
+- Split primary flavor in multibuild for possible inclusion into
+ Ring0
+
+-------------------------------------------------------------------
+Thu Jul 14 13:13:54 UTC 2022 - Ben Greiner
+
+- Setuptools itself does not depend on packaging anymore, only for
+ pythondistdeps.py, That dependency will move to
+ python-rpm-packaging soon. -- boo#1178257
+- Use "setuptools" for building again.
+ * Python 3.12 will drop the distutils fallback
+ * Use the python-base vendored pip in a venv
+ * Drop no-legacyversion-warning.patch
+- Remove nonsensical python362 flavor check.
+
-------------------------------------------------------------------
Sun May 29 09:22:42 UTC 2022 - John Paul Adrian Glaubitz
diff --git a/python-packaging.spec b/python-packaging.spec
index 08b66b2..37d357a 100644
--- a/python-packaging.spec
+++ b/python-packaging.spec
@@ -16,49 +16,72 @@
#
-%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define modname packaging
+# fallback if primary_python is not available from the project configuration
+%{?!primary_python:%define primary_python python3%{?!sle_version:10}}
+# in order to avoid rewriting for subpackage generator
+%define mypython python
%global flavor @BUILD_FLAVOR@%{nil}
+%if "%{flavor}" == "primary"
+# this one is goes into Ring0
+%define pprefix %{primary_python}
+%define pythons %{primary_python}
+# Avoid cycle with python-rpm-packaging requiring python3-packaging
+#!BuildIgnore: python3-packaging
+%endif
+%if "%{flavor}" == ""
+# The rest is in Ring1
+%define pprefix python
+%if 0%{suse_version} >= 1550 || 0%{?sle_version} == 150500
+%{expand:%%define skip_%{primary_python} 1}
+BuildRequires: python3-packaging
+%else
+# no non-primary python in <=15.4
+ExclusiveArch: do-not-build
+%define python_module() no-build-without-multibuild-flavor
+%endif
+%endif
%if "%{flavor}" == "test"
+%define pprefix python
%define psuffix -test
%bcond_without test
%else
-%define psuffix %{nil}
%bcond_with test
%endif
-# in order to avoid rewriting for subpackage generator
-%define mypython python
-%global skip_python2 1
-Name: python-packaging%{psuffix}
+%{?!python_module:%define python_module() python3-%{**}}
+%define skip_python2 1
+Name: %{pprefix}-packaging%{?psuffix}
Version: 21.3
Release: 0
Summary: Core utilities for Python packages
-License: Apache-2.0
+License: Apache-2.0 AND BSD-2-Clause
URL: https://github.com/pypa/packaging
Source: https://files.pythonhosted.org/packages/source/p/packaging/packaging-%{version}.tar.gz
-# Restore compatibility with 20.4 for setuptools
-Patch1: no-legacyversion-warning.patch
# Fix testsuite on big-endian systems
# see: https://github.com/pypa/packaging/pull/538
Patch2: fix-big-endian-build.patch
-BuildRequires: %{python_module devel}
+BuildRequires: %{python_module base >= 3.6}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
#!BuildIgnore: post-build-checks-malwarescan
-Requires: python-pyparsing >= 2.0.2
+# ! Do not add setuptools build dependency here, so that the primary package can be in Ring0 !
+# ! Also make sure all runtime dependencies don't require setuptools. !
BuildArch: noarch
-# do not add setuptools dependency, this is now a dependency
-# of setuptools. Ensure that all dependencies also don't depend
-# on setuptools
-# (at the moment, six and pyparsing are ok)
%if %{with test}
+BuildRequires: %{python_module packaging = %{version}}
BuildRequires: %{python_module pretend}
-BuildRequires: %{python_module pyparsing >= 2.0.2}
BuildRequires: %{python_module pytest}
%endif
-# work around boo#1186870
-Provides: %{mypython}%{python_version}dist(packaging) = %{version}-%{release}
-%if "%{python_flavor}" == "python3" || "%{python_provides}" == "python3"
-Provides: %{mypython}3dist(packaging) = %{version}-%{release}
+%if "%{flavor}" == "primary"
+# See boo#1186870, we can't provide ourselves to pythondistdeps.py
+Provides: %{mypython}%{python_version}dist(%{modname}) = %{version}-%{release}
+Provides: %{mypython}3-%{modname} = %{version}-%{release}
+Provides: %{mypython}3dist(%{modname}) = %{version}-%{release}
+Obsoletes: %{mypython}3-%{modname} < %{version}-%{release}
+Requires: %{primary_python}-pyparsing >= 2.0.2
+Requires: %{mypython}(abi) = %{python_version}
+%else
+Requires: python-pyparsing >= 2.0.2
%endif
%python_subpackages
@@ -67,37 +90,38 @@ Core utilities for Python packages
%prep
%autosetup -p1 -n packaging-%{version}
-# sdist must provide a packaging.egg-info, used below in install phase
-test -d packaging.egg-info
+%if !%{with test}
%build
-%python_build
-
-%if %{with test}
-%check
-%if "%{python_flavor}" >= "python362"
-# no-legacyversion-warning.patch causes these to fail
-%pytest -k "not (test_legacy_specifier_is_deprecated or test_legacy_version_is_deprecated)"
+%{python_expand # build using pythonXX-base bundled setuptools
+$python -m venv venv-%{$python_bin_suffix}
+venv-%{$python_bin_suffix}/bin/python setup.py build
+}
%endif
-%endif # %%{with_test}
%if !%{with test}
%install
-%python_install
-# Replace distutils generated egg-info, which varies in metadata version and
-# structure (single file vs directory) based on distutils, with the egg-info
-# which is provided in the sdist and uses same metadata version as setuptools.
-%{python_expand rm -r %{buildroot}%{$python_sitelib}/*.egg-info
-cp -r packaging.egg-info %{buildroot}%{$python_sitelib}/packaging-%{version}-py%{$python_version}.egg-info
+%{python_expand # install using pythonXX-base bundled setuptools.
+# This will work until deprecated support of setup.py install is removed from the bundled setuptools.
+# Hopefully upstream packaging comes up with a better bootstrapping process by then.
+# (https://github.com/pypa/packaging/pull/536, https://github.com/pypa/packaging/pull/546)
+venv-%{$python_bin_suffix}/bin/python setup.py install \
+ -O1 --skip-build --force --root %{buildroot} --prefix %{_prefix}
+%fdupes %{buildroot}%{$python_sitelib}
}
-%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%endif
+%if %{with test}
+%check
+%pytest
+%endif
+
+%if !%{with test}
%files %{python_files}
%license LICENSE LICENSE.APACHE LICENSE.BSD
%doc CHANGELOG.rst README.rst
%{python_sitelib}/packaging
-%{python_sitelib}/packaging-%{version}-py*.egg-info/
-
-%endif # !%%{with_test}
+%{python_sitelib}/packaging-%{version}*-info
+%endif
%changelog