From 864c720e58ad135b14819e8ecbef575a6d6725e5 Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Sun, 1 Sep 2024 16:15:21 -0400 Subject: [PATCH] mongodb: fix building with python312 --- pkgs/servers/nosql/mongodb/5.0.nix | 2 ++ pkgs/servers/nosql/mongodb/6.0.nix | 3 +++ .../nosql/mongodb/mongodb-python312.patch | 22 +++++++++++++++++++ pkgs/servers/nosql/mongodb/mongodb.nix | 4 ++-- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 pkgs/servers/nosql/mongodb/mongodb-python312.patch diff --git a/pkgs/servers/nosql/mongodb/5.0.nix b/pkgs/servers/nosql/mongodb/5.0.nix index 1738ba2f05e1c..5f93244442ecf 100644 --- a/pkgs/servers/nosql/mongodb/5.0.nix +++ b/pkgs/servers/nosql/mongodb/5.0.nix @@ -29,6 +29,8 @@ buildMongoDB { ./forget-build-dependencies-4-4.patch ./asio-no-experimental-string-view-4-4.patch ./fix-gcc-Wno-exceptions-5.0.patch + # Fix building with python 3.12 since the imp module was removed + ./mongodb-python312.patch ] ++ variants.patches; passthru.tests = { inherit (nixosTests) mongodb; }; } diff --git a/pkgs/servers/nosql/mongodb/6.0.nix b/pkgs/servers/nosql/mongodb/6.0.nix index 170aeec068cf4..7132039908b06 100644 --- a/pkgs/servers/nosql/mongodb/6.0.nix +++ b/pkgs/servers/nosql/mongodb/6.0.nix @@ -21,6 +21,9 @@ buildMongoDB { url = "https://github.com/mongodb/mongo/commit/5435f9585f857f6145beaf6d31daf336453ba86f.patch"; sha256 = "sha256-gWlE2b/NyGe2243iNCXzjcERIY8/4ZWI4Gjh5SF0tYA="; }) + + # Fix building with python 3.12 since the imp module was removed + ./mongodb-python312.patch ]; # passthru.tests = { inherit (nixosTests) mongodb; }; # currently tests mongodb-5_0 } diff --git a/pkgs/servers/nosql/mongodb/mongodb-python312.patch b/pkgs/servers/nosql/mongodb/mongodb-python312.patch new file mode 100644 index 0000000000000..c0fa630dddca4 --- /dev/null +++ b/pkgs/servers/nosql/mongodb/mongodb-python312.patch @@ -0,0 +1,22 @@ +diff --git a/buildscripts/moduleconfig.py b/buildscripts/moduleconfig.py +index b4d0bba0490..f59ddd7bc5c 100644 +--- a/buildscripts/moduleconfig.py ++++ b/buildscripts/moduleconfig.py +@@ -27,7 +27,7 @@ MongoDB SConscript files do. + __all__ = ('discover_modules', 'discover_module_directories', 'configure_modules', + 'register_module_test') # pylint: disable=undefined-all-variable + +-import imp ++import importlib + import inspect + import os + +@@ -71,7 +71,7 @@ def discover_modules(module_root, allowed_modules): + print("adding module: %s" % (name)) + fp = open(build_py, "r") + try: +- module = imp.load_module("module_" + name, fp, build_py, ++ module = importlib.load_module("module_" + name, fp, build_py, + (".py", "r", imp.PY_SOURCE)) + if getattr(module, "name", None) is None: + module.name = name diff --git a/pkgs/servers/nosql/mongodb/mongodb.nix b/pkgs/servers/nosql/mongodb/mongodb.nix index 47d788b753e3b..9c26f5fa701db 100644 --- a/pkgs/servers/nosql/mongodb/mongodb.nix +++ b/pkgs/servers/nosql/mongodb/mongodb.nix @@ -13,7 +13,6 @@ , openldap , openssl , libpcap -, python311Packages , curl , Security , CoreFoundation @@ -32,12 +31,13 @@ }: let - scons = buildPackages.scons.override{ python3Packages = python311Packages; }; + scons = buildPackages.scons; python = scons.python.withPackages (ps: with ps; [ pyyaml cheetah3 psutil setuptools + distutils ] ++ lib.optionals (lib.versionAtLeast version "6.0") [ packaging pymongo