]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
python_hatchling: remove empty python sysroot dirs
authorTrevor Gamblin <tgamblin@baylibre.com>
Thu, 1 Jun 2023 13:56:29 +0000 (09:56 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 2 Jun 2023 13:41:46 +0000 (14:41 +0100)
In some cases, empty versioned directories are being left behind in
sysroots from previous versions of packages. This appears to be found
with recipes relying on hatchling, and causes errors at the do_compile
step:

|   File "/workspace/yocto/manual/openembedded-core/build/tmp-glibc/work/core2-64-oe-linux/python3-iniconfig/2.0.0-r0/recipe-sysroot-native/usr/lib/python3.11/site-packages/packaging/version.py", line 197, in __init__
|     match = self._regex.search(version)
|             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| TypeError: expected string or bytes-like object, got 'NoneType'

To fix this error, add a do_prepare_recipe_sysroot postfunc in the
python_hatchling class that removes any nested empty directories from
the sysroots during build, so that dependent recipes don't get caught
on them.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/python_hatchling.bbclass

index b9e6582eb509be71452122a5bd10ef9f0a3e8f72..b5a3c3feea55e8353b6cb147cd537a5a3e5973d7 100644 (file)
@@ -7,3 +7,21 @@
 inherit python_pep517 python3native python3-dir setuptools3-base
 
 DEPENDS += "python3-hatchling-native"
+
+# delete nested, empty directories from the python site-packages path. Make
+# sure that we remove the native ones for target builds as well
+hatchling_rm_emptydirs:class-target () {
+        find ${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/* -depth -type d -empty -delete
+        find ${STAGING_LIBDIR_NATIVE}/${PYTHON_DIR}/site-packages/* -depth -type d -empty -delete
+}
+
+hatchling_rm_emptydirs:class-native () {
+        find ${STAGING_LIBDIR_NATIVE}/${PYTHON_DIR}/site-packages/* -depth -type d -empty -delete
+}
+
+# Define a default empty version of hatchling_rm_emptydirs to appease bitbake
+hatchling_rm_emptydirs () {
+        :
+}
+
+do_prepare_recipe_sysroot[postfuncs] += " hatchling_rm_emptydirs"