summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAwais Belal <awais.belal@gmail.com>2025-03-07 14:32:54 +0500
committerArmin Kuster <akuster808@gmail.com>2025-03-07 19:40:51 -0500
commitedd1a1e284fdcb80cd48d411f235d47f23bc27ae (patch)
tree57d9ad544cb98429b04b1a9c2c5ed1d80bea39bb
parent73e6789fdfdd31a8b512aedb59dfe9cfd5b40342 (diff)
downloadmeta-openembedded-edd1a1e284fdcb80cd48d411f235d47f23bc27ae.tar.gz
mongodb: fix build with python 3.12
The moduleconfig.py build script uses the 'imp' module which is deprecated in favor of 'importlib' in python 3.12. This fixes the build issue by replacing the affected portion of the code and the package now builds fine on hosts with python 3.12. Signed-off-by: Awais Belal <awais.belal@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb/0001-moduleconfig.py-python-3.12-compatibility.patch57
-rw-r--r--meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb_git.bb3
2 files changed, 58 insertions, 2 deletions
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb/0001-moduleconfig.py-python-3.12-compatibility.patch b/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb/0001-moduleconfig.py-python-3.12-compatibility.patch
new file mode 100644
index 0000000000..51926b9d2e
--- /dev/null
+++ b/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb/0001-moduleconfig.py-python-3.12-compatibility.patch
@@ -0,0 +1,57 @@
1From 37580777bc5294d606584f3731d9f5f5425bb587 Mon Sep 17 00:00:00 2001
2From: Awais B <awais.b@rufilla.com>
3Date: Tue, 4 Mar 2025 11:27:10 +0000
4Subject: [PATCH] moduleconfig.py: python 3.12 compatibility
5
6The imp module was deprecated in python 3.4 and is dropped
7with python 3.12. We now need to use importlib for the
8purpose of manipulating/loading modules.
9
10Upstream-Status: Pending
11Signed-off-by: Awais B <awais.b@rufilla.com>
12---
13 buildscripts/moduleconfig.py | 21 ++++++++++++++-------
14 1 file changed, 14 insertions(+), 7 deletions(-)
15
16diff --git a/buildscripts/moduleconfig.py b/buildscripts/moduleconfig.py
17index b4d0bba0490..69dd91ab30d 100644
18--- a/buildscripts/moduleconfig.py
19+++ b/buildscripts/moduleconfig.py
20@@ -27,7 +27,8 @@ MongoDB SConscript files do.
21 __all__ = ('discover_modules', 'discover_module_directories', 'configure_modules',
22 'register_module_test') # pylint: disable=undefined-all-variable
23
24-import imp
25+import importlib
26+import sys
27 import inspect
28 import os
29
30@@ -71,12 +72,18 @@ def discover_modules(module_root, allowed_modules):
31 print("adding module: %s" % (name))
32 fp = open(build_py, "r")
33 try:
34- module = imp.load_module("module_" + name, fp, build_py,
35- (".py", "r", imp.PY_SOURCE))
36- if getattr(module, "name", None) is None:
37- module.name = name
38- found_modules.append(module)
39- found_module_names.append(name)
40+ module_name = "module_" + name
41+ module_spec = importlib.util.spec_from_file_location(module_name, build_py)
42+
43+ if module_spec is not None:
44+ module = importlib.util.module_from_spec(module_spec)
45+ sys.modules[module_name] = module
46+ module_spec.loader.exec_module(module)
47+
48+ if not hasattr(module, "name"):
49+ module.name = name
50+ found_modules.append(module)
51+ found_module_names.append(name)
52 finally:
53 fp.close()
54 except (FileNotFoundError, IOError):
55--
562.34.1
57
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb_git.bb b/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb_git.bb
index ee5c77a85d..f7fd881713 100644
--- a/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb_git.bb
+++ b/meta-oe/dynamic-layers/meta-python/recipes-dbs/mongodb/mongodb_git.bb
@@ -36,6 +36,7 @@ SRC_URI = "git://github.com/mongodb/mongo.git;branch=v4.4;protocol=https \
36 file://0001-apply-msvc-workaround-for-clang-16.patch \ 36 file://0001-apply-msvc-workaround-for-clang-16.patch \
37 file://0001-Fix-type-mismatch-on-32bit-arches.patch \ 37 file://0001-Fix-type-mismatch-on-32bit-arches.patch \
38 file://0001-Fix-build-on-32bit.patch \ 38 file://0001-Fix-build-on-32bit.patch \
39 file://0001-moduleconfig.py-python-3.12-compatibility.patch \
39 " 40 "
40SRC_URI:append:libc-musl ="\ 41SRC_URI:append:libc-musl ="\
41 file://0001-Mark-one-of-strerror_r-implementation-glibc-specific.patch \ 42 file://0001-Mark-one-of-strerror_r-implementation-glibc-specific.patch \
@@ -145,5 +146,3 @@ SYSTEMD_SERVICE:${PN} = "mongod.service"
145FILES:${PN} += "${nonarch_libdir}/tmpfiles.d" 146FILES:${PN} += "${nonarch_libdir}/tmpfiles.d"
146 147
147RDEPENDS:${PN} += "tzdata-core" 148RDEPENDS:${PN} += "tzdata-core"
148
149SKIP_RECIPE[mongodb] ?= "Needs porting to python 3.12"