Skip to contentSkip to conversation

lib/oe: remove redundant __name__ == "__main__" checks

PATCH New Ross Burton 1 participant 3 messages Apr 2, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 lib/oe: remove redundant __name__ == "__main__" checks

There's no point in checking if __name__ == "__main__" (i.e., is this module being invoked) and then doing nothing.

---
 meta/lib/oe/manifest.py | 4 ----
 meta/lib/oe/rootfs.py   | 9 ---------
 meta/lib/oe/sdk.py      | 3 ---
 3 files changed, 16 deletions(-)
meta/lib/oe/manifest.py +0 -4
index 61f18adc4ac..cf7a13c2475 100644
@@ -200,7 +200,3 @@ def create_manifest(d, final_manifest=False, manifest_dir=None,
         manifest.create_final()
     else:
         manifest.create_initial()
-
-
-if __name__ == "__main__":
-    pass
meta/lib/oe/rootfs.py +0 -9
index 90d49749653..6b56adaf031 100644
@@ -427,12 +427,3 @@ def image_list_installed_packages(d, rootfs_dir=None):
     import importlib
     cls = importlib.import_module('oe.package_manager.' + img_type)
     return cls.PMPkgsList(d, rootfs_dir).list_pkgs()
-
-if __name__ == "__main__":
-    """
-    We should be able to run this as a standalone script, from outside bitbake
-    environment.
-    """
-    """
-    TBD
-    """
meta/lib/oe/sdk.py +0 -3
index 3dc3672210b..11759aba489 100644
@@ -155,6 +155,3 @@ def get_extra_sdkinfo(sstate_dir):
                 extra_info['tasksizes'][task] = origtotal + fsize
                 extra_info['filesizes'][fn] = fsize
     return extra_info
-
-if __name__ == "__main__":
-    pass
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/3 python3: remove obsolete deletion of non-deterministic .pyc files

These .pyc files were non-deterministic because they used frozensets[1], but this has been fixed in 3.11 onwards.

[1] https://github.com/python/cpython/issues/81777
[2] https://github.com/python/cpython/commit/51999c960e7fc45feebd629421dec6524a5fc803

---
 meta/recipes-devtools/python/python3_3.13.2.bb | 14 --------------
 1 file changed, 14 deletions(-)
meta/recipes-devtools/python/python3_3.13.2.bb +0 -14
index 7c36fd92ed7..0f0505c66c7 100644
@@ -235,20 +235,6 @@ do_install:append() {
                 $sysconfigfile
         cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
 
-
-        # Unfortunately the following pyc files are non-deterministc due to 'frozenset'
-        # being written without strict ordering, even with PYTHONHASHSEED = 0
-        # Upstream is discussing ways to solve the issue properly, until then let's
-        # just not install the problematic files.
-        # More info: http://benno.id.au/blog/2013/01/15/python-determinism
-        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
-        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
-
-        # Similar to the above, we're getting reproducibility issues with 
-        # /usr/lib/python3.10/__pycache__/traceback.cpython-310.pyc
-        # so remove it too
-        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/traceback.cpython*
-
         # Remove the opt-1.pyc and opt-2.pyc files. They effectively waste space on embedded
         # style targets as they're only used when python is called with the -O or -OO options
         # which is rare.
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/3 meson: upgrade to 1.7.1

In reply to Ross Burton

Drop 0001-dependencies-dev-prepend-sysroot-when-searching-for-.patch as this is now upstreamed.

Remove the deletion of a .pyc because it uses frozenset(), this bug in Python has been fixed since 3.11[1]

[1] https://github.com/python/cpython/commit/51999c960e7fc45feebd629421dec6524a5fc803

---
 ...-prepend-sysroot-when-searching-for-.patch | 33 -------------------
 .../meson/{meson_1.7.0.bb => meson_1.7.1.bb}  | 13 +-------
 2 files changed, 1 insertion(+), 45 deletions(-)
 delete mode 100644 meta/recipes-devtools/meson/meson/0001-dependencies-dev-prepend-sysroot-when-searching-for-.patch
 rename meta/recipes-devtools/meson/{meson_1.7.0.bb => meson_1.7.1.bb} (88%)
meta/recipes-devtools/meson/meson/0001-dependencies-dev-prepend-sysroot-when-searching-for-.patch deleted +0 -33
deleted file mode 100644
index b6579c824ef..00000000000
@@ -1,33 +0,0 @@
-From 17117c2732c33ebec39e3fec2ecd5a3515dc7d71 Mon Sep 17 00:00:00 2001
-From: Ross Burton <[email protected]>
-Date: Wed, 20 Nov 2024 13:09:38 +0000
-Subject: [PATCH] dependencies/dev: prepend sysroot when searching for GTest
- sources
-
-Don't hardcode paths in /usr when looking for the GTest sources, as in
-cross-compile or other builds with a sysroot this will find the host
-sources, not ones that we want to use in the sysroot.
-
-Closes #12690.
-
-Upstream-Status: Backport [17117c2732c33ebec39e3fec2ecd5a3515dc7d71]
-Signed-off-by: Ross Burton <[email protected]>
----
- mesonbuild/dependencies/dev.py | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
-index 2725a7bb4e88..0c8886b81a04 100644
---- a/mesonbuild/dependencies/dev.py
-+++ b/mesonbuild/dependencies/dev.py
-@@ -56,7 +56,9 @@ class GTestDependencySystem(SystemDependency):
-     def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None:
-         super().__init__(name, environment, kwargs, language='cpp')
-         self.main = kwargs.get('main', False)
--        self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src']
-+
-+        sysroot = environment.properties[self.for_machine].get_sys_root() or ''
-+        self.src_dirs = [sysroot + '/usr/src/gtest/src', sysroot + '/usr/src/googletest/googletest/src']
-         if not self._add_sub_dependency(threads_factory(environment, self.for_machine, {})):
-             self.is_found = False
-             return
meta/recipes-devtools/meson/meson_1.7.1.bb renamed from meta/recipes-devtools/meson/meson_1.7.0.bb +1 -12
similarity index 88%
rename from meta/recipes-devtools/meson/meson_1.7.0.bb
rename to meta/recipes-devtools/meson/meson_1.7.1.bb
index 44872a5f7ba..d83a5efbf5d 100644
@@ -14,9 +14,8 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \
            file://0001-python-module-do-not-manipulate-the-environment-when.patch \
            file://0001-Make-CPU-family-warnings-fatal.patch \
            file://0002-Support-building-allarch-recipes-again.patch \
-           file://0001-dependencies-dev-prepend-sysroot-when-searching-for-.patch \
            "
-SRC_URI[sha256sum] = "08efbe84803eed07f863b05092d653a9d348f7038761d900412fddf56deb0284"
+SRC_URI[sha256sum] = "155780a5be87f6dd7f427ad8bcbf0f2b2c5f62ee5fdacca7caa9de8439a24b89"
 UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)$"
 
 inherit python_setuptools_build_meta github-releases
@@ -25,16 +24,6 @@ RDEPENDS:${PN} = "ninja python3-modules python3-pkg-resources"
 
 FILES:${PN} += "${datadir}/polkit-1"
 
-do_install:append () {
-	# As per the same issue in the python recipe itself:
-	# Unfortunately the following pyc files are non-deterministc due to 'frozenset'
-	# being written without strict ordering, even with PYTHONHASHSEED = 0
-	# Upstream is discussing ways to solve the issue properly, until then let's
-	# just not install the problematic files.
-	# More info: http://benno.id.au/blog/2013/01/15/python-determinism
-	rm -f ${D}${libdir}/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython*
-}
-
 BBCLASSEXTEND = "native nativesdk"
 
 inherit meson-routines
Signature · 1 line
2.43.0