Skip to content

Commit

Permalink
mongodb: fix building with python312
Browse files Browse the repository at this point in the history
  • Loading branch information
qubitnano committed Sep 2, 2024
1 parent a9a40a5 commit 864c720
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkgs/servers/nosql/mongodb/5.0.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
}
3 changes: 3 additions & 0 deletions pkgs/servers/nosql/mongodb/6.0.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
22 changes: 22 additions & 0 deletions pkgs/servers/nosql/mongodb/mongodb-python312.patch
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions pkgs/servers/nosql/mongodb/mongodb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
, openldap
, openssl
, libpcap
, python311Packages
, curl
, Security
, CoreFoundation
Expand All @@ -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
Expand Down

0 comments on commit 864c720

Please sign in to comment.