From 56868f0f9b01c9eae6c465e4258ebd81b1018b3a Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 9 Jan 2023 14:02:40 +0200 Subject: [PATCH] Drop setup.py based Python build (#2135561, #2149762) The setup.py build was only really added for dealing with parallel installable Python 2 and 3 builds, and has been quite a PITA otherwise because it's not what the upstream builds and tests use. Now that the 2to3 transition is thankfully over, we can go back to building the extension by ourselves. Only, in the meanwhile people have come to depend on the egg-info data so create that from automake, that format is not exactly rocket science. This fixes us accidentally shipping two slightly different Python modules for years (#2135719) and building with Python >= 3.12 where distutils has been dropped, and does so in upstream compatible manner (where a similar approach was taken when transitioning to cmake based build system) --- ...Python-egg-info-from-automake-builds.patch | 82 +++++++++++++++++++ rpm.spec | 20 ++--- 2 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 0001-Generate-Python-egg-info-from-automake-builds.patch diff --git a/0001-Generate-Python-egg-info-from-automake-builds.patch b/0001-Generate-Python-egg-info-from-automake-builds.patch new file mode 100644 index 0000000..539f67c --- /dev/null +++ b/0001-Generate-Python-egg-info-from-automake-builds.patch @@ -0,0 +1,82 @@ +From de0b9d142ad8bada4d49afeee95616fee265d44f Mon Sep 17 00:00:00 2001 +Message-Id: +From: Panu Matilainen +Date: Mon, 9 Jan 2023 12:56:34 +0200 +Subject: [PATCH] Generate Python egg-info from automake builds + +To compensate for the loss of egg-info from the python distutils build, +create one ourselves. + +This is effectively a backport of e31fb5b75898bfa09180dba02475c6d01764d94f +which dismissed the need for an automake version, but unfortunately Python +3.12 and automake-based rpm versions do co-exist in the same time-space +continuum and we'll have to deal with this in rpm 4.18 as well. + +As to why not just use distutils from python-setuptools: that variant +turns the egg-info into a directory, which in rpm is a one-way street. +And we don't need that multi megabyte Python library to fill in these +couple of values, really. +--- + configure.ac | 1 + + python/Makefile.am | 9 ++++++++- + python/rpm.egg-info.in | 10 ++++++++++ + 3 files changed, 19 insertions(+), 1 deletion(-) + create mode 100644 python/rpm.egg-info.in + +diff --git a/configure.ac b/configure.ac +index fbbfead89..5f5842590 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -964,5 +964,6 @@ AC_CONFIG_FILES([Makefile + tests/Makefile + plugins/Makefile + python/setup.py ++ python/rpm.egg-info + ]) + AC_OUTPUT +diff --git a/python/Makefile.am b/python/Makefile.am +index ec3608134..04168406d 100644 +--- a/python/Makefile.am ++++ b/python/Makefile.am +@@ -3,14 +3,21 @@ + include $(top_srcdir)/rpm.am + AM_CFLAGS = @RPMCFLAGS@ + +-EXTRA_DIST = rpm/__init__.py rpm/transaction.py ++CLEANFILES = ++EXTRA_DIST = rpm/__init__.py rpm/transaction.py rpm.egg-info.in + + AM_CPPFLAGS = -I$(top_srcdir)/include/ + AM_CPPFLAGS += -I$(top_srcdir)/python + AM_CPPFLAGS += @PYTHON_CFLAGS@ + ++egginfo = $(PACKAGE_NAME)-$(PACKAGE_VERSION)-py$(PYTHON_VERSION).egg-info ++$(egginfo): ++ cat rpm.egg-info > $(egginfo) ++CLEANFILES += $(egginfo) ++ + pkgpyexec_LTLIBRARIES = _rpm.la + pkgpyexec_DATA = rpm/__init__.py rpm/transaction.py ++pyexec_DATA = $(egginfo) + + _rpm_la_LDFLAGS = -module -avoid-version -shared + _rpm_la_LIBADD = \ +diff --git a/python/rpm.egg-info.in b/python/rpm.egg-info.in +new file mode 100644 +index 000000000..838ce5854 +--- /dev/null ++++ b/python/rpm.egg-info.in +@@ -0,0 +1,10 @@ ++Metadata-Version: 1.0 ++Name: @PACKAGE_NAME@ ++Version: @PACKAGE_VERSION@ ++Summary: Python bindings for rpm ++Home-page: @PACKAGE_URL@ ++Author: Rpm community ++Author-email: rpm-maint@lists.rpm.org ++License: GNU General Public License v2 ++Description: Python bindings for rpm ++Platform: UNKNOWN +-- +2.39.0 + diff --git a/rpm.spec b/rpm.spec index 2b0851d..10d10b5 100644 --- a/rpm.spec +++ b/rpm.spec @@ -136,6 +136,7 @@ rpm-4.9.90-no-man-dirs.patch # Patches already upstream: # ... 0001-Fix-potential-uninitialized-variable-use-in-rpmtsImp.patch +0001-Generate-Python-egg-info-from-automake-builds.patch # These are not yet upstream rpm-4.7.1-geode-i686.patch @@ -384,19 +385,9 @@ done; %make_build -pushd python -%py3_build -popd - %install %make_install -# We need to build with --enable-python for the self-test suite, but we -# actually package the bindings built with setup.py (#531543#c26) -pushd python -%py3_install -popd - mkdir -p $RPM_BUILD_ROOT%{_unitdir} install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/%{_unitdir} install -m 644 %{SOURCE20} $RPM_BUILD_ROOT/%{_unitdir} @@ -604,8 +595,11 @@ fi %{_mandir}/man8/rpmsign.8* %files -n python3-%{name} -%{python3_sitearch}/rpm/ %{python3_sitearch}/rpm-%{rpmver}*.egg-info +%{python3_sitearch}/rpm/__init__.py +%{python3_sitearch}/rpm/transaction.py +%{python3_sitearch}/rpm/_rpm.so +%artifact %{python3_sitearch}/rpm/__pycache__/ %files devel %{_mandir}/man8/rpmgraph.8* @@ -623,6 +617,10 @@ fi %doc docs/librpm/html/* %changelog +* Mon Jan 09 2023 Panu Matilainen - 4.18.0-9 +- Generate Python egg-info from automake (#2135561) +- Drop setup.py-based Python build (#2135719) + * Wed Dec 07 2022 Panu Matilainen - 4.18.0-8 - Fix hang-up on failed key import (related to #2149762)