diff mbox series

[4/6] rpm: handle CMake Python paths in EXTRA_OECMAKE

Message ID 20251216143901.2542490-5-tgamblin@baylibre.com
State New
Headers show
Series python3: upgrade 3.13.9 -> 3.14.2 | expand

Commit Message

Trevor Gamblin Dec. 16, 2025, 2:38 p.m. UTC
With the Python 3.14.0 upgrade, rpm is finding the wrong paths with
CMake, leading to a QA issue for files that we have listed in FILES
already:

|ERROR: QA Issue: rpm: Files/directories were installed but not shipped in any package:
|  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm-4.20.1-py3.14.egg-info
|  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm/_rpm.so
|  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm/transaction.py
|  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm/__init__.py
|Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
|rpm: 4 installed and not shipped files. [installed-vs-shipped]

Add a patch to make it possible to override Python3_SITEARCH in rpm's
python/CMakeLists.txt by setting PYTHON_INSTALL_DIR in EXTRA_OECMAKE.

Build looks OK, as does reproducibility:

|2025-12-12 12:29:00,504 - oe-selftest - INFO - Adding: "include selftest.inc" in /home/tgamblin/workspace/yocto/openembedded-core/build-st/conf/local.conf
|2025-12-12 12:29:00,504 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
|2025-12-12 12:29:00,504 - oe-selftest - INFO - test_reproducible_builds (reproducible.ReproducibleTests.test_reproducible_builds)
|2025-12-12 12:30:41,633 - oe-selftest - INFO - Building reproducibleA (sstate allowed)...
|2025-12-12 12:35:08,628 - oe-selftest - INFO - Building reproducibleB-extended (sstate NOT allowed)...
|2025-12-12 12:54:33,755 - oe-selftest - INFO - Checking deb packages for differences...
|2025-12-12 12:54:34,147 - oe-selftest - INFO - Reproducibility summary for deb: same=937 different=0 different_excluded=0 missing=0 total=937
|unused_exclusions=[]
|2025-12-12 12:54:34,148 - oe-selftest - INFO - Checking ipk packages for differences...
|2025-12-12 12:54:34,427 - oe-selftest - INFO - Reproducibility summary for ipk: same=937 different=0 different_excluded=0 missing=0 total=937
|unused_exclusions=[]
|2025-12-12 12:54:34,427 - oe-selftest - INFO - Checking rpm packages for differences...
|2025-12-12 12:54:34,655 - oe-selftest - INFO - Reproducibility summary for rpm: same=937 different=0 different_excluded=0 missing=0 total=937
|unused_exclusions=[]
|2025-12-12 12:54:34,656 - oe-selftest - INFO -  ... ok
|2025-12-12 12:56:15,651 - oe-selftest - INFO - ----------------------------------------------------------------------
|2025-12-12 12:56:15,651 - oe-selftest - INFO - Ran 1 test in 1635.716s
|2025-12-12 12:56:15,651 - oe-selftest - INFO - OK
|2025-12-12 12:56:18,842 - oe-selftest - INFO - RESULTS:
|2025-12-12 12:56:18,842 - oe-selftest - INFO - RESULTS - reproducible.ReproducibleTests.test_reproducible_builds: PASSED (1534.15s)
|2025-12-12 12:56:20,706 - oe-selftest - INFO - SUMMARY:
|2025-12-12 12:56:20,706 - oe-selftest - INFO - oe-selftest () - Ran 1 test in 1635.716s
|2025-12-12 12:56:20,706 - oe-selftest - INFO - oe-selftest - OK - All required tests passed (successes=1, skipped=0, failures=0, errors=0)

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 ...s.txt-allow-overriding-Python-instal.patch | 53 +++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_4.20.1.bb       |  3 +-
 2 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/rpm/files/0001-python-CMakeLists.txt-allow-overriding-Python-instal.patch

Comments

Alexander Kanavin Dec. 16, 2025, 7:42 p.m. UTC | #1
On Tue, 16 Dec 2025 at 15:39, Trevor Gamblin via
lists.openembedded.org <tgamblin=baylibre.com@lists.openembedded.org>
wrote:
>
> With the Python 3.14.0 upgrade, rpm is finding the wrong paths with
> CMake, leading to a QA issue for files that we have listed in FILES
> already:
>
> |ERROR: QA Issue: rpm: Files/directories were installed but not shipped in any package:
> |  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm-4.20.1-py3.14.egg-info
> |  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm/_rpm.so
> |  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm/transaction.py
> |  /home/tgamblin/workspace/yocto/openembedded-core/build/tmp/work/x86-64-v3-poky-linux/rpm/4.20.1/recipe-sysroot-native/usr/lib/python3.14/site-packages/rpm/__init__.py
> |Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
> |rpm: 4 installed and not shipped files. [installed-vs-shipped]
>
> Add a patch to make it possible to override Python3_SITEARCH in rpm's
> python/CMakeLists.txt by setting PYTHON_INSTALL_DIR in EXTRA_OECMAKE.

I'm still worried that Python3_SITEARCH was correct with the previous
version of python, and is no longer correct. We can't cover it up with
a patch that forcibly passes in the correct value to cmake, without
investigating what is happening.

Specifically, in
recipe-sysroot-native/usr/share/cmake-4.2/Modules/FindPython3.cmake I
see this:

``Python3_SITEARCH``
  Third-party platform dependent installation directory.

  Information returned by ``sysconfig.get_path('platlib')``.

And the code that actually runs python can be found in
recipe-sysroot-native/usr/share/cmake-4.2/Modules/FindPython/Support.cmake

So if "sysconfig.get_path('platlib')" (in presence of
python3targetconfig inherot, which rpm recipe does have) has indeed
regressed, it can't be left unfixed.

Alex

Alex
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rpm/files/0001-python-CMakeLists.txt-allow-overriding-Python-instal.patch b/meta/recipes-devtools/rpm/files/0001-python-CMakeLists.txt-allow-overriding-Python-instal.patch
new file mode 100644
index 0000000000..bd04c49261
--- /dev/null
+++ b/meta/recipes-devtools/rpm/files/0001-python-CMakeLists.txt-allow-overriding-Python-instal.patch
@@ -0,0 +1,53 @@ 
+From a5c21ca9c925aac2ea43a443a31e390a6dfe5e40 Mon Sep 17 00:00:00 2001
+From: Trevor Gamblin <tgamblin@baylibre.com>
+Date: Fri, 12 Dec 2025 10:59:24 -0500
+Subject: [PATCH] python/CMakeLists.txt: allow overriding Python install dir
+
+Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/4072]
+
+Allow optionally overriding the PYTHON_INSTALL_DIR variable instead of
+relying solely on the value of Python3_SITEARCH. This is useful for
+cross-compilation scenarios as of Python 3.14 (which has stricter
+sysconfig settings), e.g. with Yocto builds, where Python files get
+installed to native instead of target paths. In such cases the
+FindPython3 function may find the native version and use those sysconfig
+values, which is incorrect.
+
+If PYTHON_INSTALL_DIR is not set, we continue using the computed value
+of Python3_SITEARCH.
+
+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
+---
+ python/CMakeLists.txt | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
+index 21f89edfd..4eca82129 100644
+--- a/python/CMakeLists.txt
++++ b/python/CMakeLists.txt
+@@ -23,13 +23,19 @@ target_compile_definitions(_rpm PRIVATE Py_LIMITED_API=0x030A0000)
+ 
+ target_link_libraries(_rpm PRIVATE librpmio librpm librpmbuild librpmsign)
+ 
++# Allow overriding of Python installation directory for cross-compilation
++# scenarios
++if(NOT DEFINED PYTHON_INSTALL_DIR)
++	set(PYTHON_INSTALL_DIR ${Python3_SITEARCH})
++endif()
++
+ install(TARGETS _rpm
+-	DESTINATION ${Python3_SITEARCH}/rpm)
++	DESTINATION ${PYTHON_INSTALL_DIR}/rpm)
+ install(FILES rpm/transaction.py rpm/__init__.py
+-	DESTINATION ${Python3_SITEARCH}/rpm)
++	DESTINATION ${PYTHON_INSTALL_DIR}/rpm)
+ install(DIRECTORY examples TYPE DOC)
+ 
+ set(egginfo ${PROJECT_NAME}-${PROJECT_VERSION}-py${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.egg-info)
+ configure_file(rpm.egg-info.in ${egginfo} @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${egginfo}
+-	DESTINATION ${Python3_SITEARCH})
++	DESTINATION ${PYTHON_INSTALL_DIR})
+-- 
+2.52.0
+
diff --git a/meta/recipes-devtools/rpm/rpm_4.20.1.bb b/meta/recipes-devtools/rpm/rpm_4.20.1.bb
index ba967ec1fa..803fa272dc 100644
--- a/meta/recipes-devtools/rpm/rpm_4.20.1.bb
+++ b/meta/recipes-devtools/rpm/rpm_4.20.1.bb
@@ -39,6 +39,7 @@  SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.20.x;protoc
            file://0002-rpmio-rpmglob.c-avoid-using-GLOB_BRACE-if-undefined-.patch \
            file://0001-CMakeLists.txt-set-libdir-to-CMAKE_INSTALL_FULL_LIBD.patch \
            file://0001-CMakeLists.txt-Fix-checking-for-CFLAGS.patch \
+	   file://0001-python-CMakeLists.txt-allow-overriding-Python-instal.patch \
            "
 
 PE = "1"
@@ -47,7 +48,7 @@  SRCREV = "c8dc5ea575a2e9c1488036d12f4b75f6a5a49120"
 DEPENDS = "lua libgcrypt file popt xz bzip2 elfutils python3 sqlite3 zstd"
 DEPENDS:append:class-native = " file-replacement-native bzip2-replacement-native"
 
-EXTRA_OECMAKE:append = " -D__CURL:FILEPATH=curl"
+EXTRA_OECMAKE:append = " -D__CURL:FILEPATH=curl -DPYTHON_INSTALL_DIR=${PYTHON_SITEPACKAGES_DIR}"
 EXTRA_OECMAKE:append:libc-musl = " -DENABLE_NLS=OFF -DENABLE_OPENMP=OFF"
 
 # --sysconfdir prevents rpm from attempting to access machine-specific configuration in sysroot/etc; we need to have it in rootfs