Skip to content

Commit c33668e

Browse files
committed
python312Packages.carbon: fix routers.py
1 parent 3a3e15f commit c33668e

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

pkgs/development/python-modules/carbon/default.nix

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
cachetools,
55
fetchPypi,
66
nixosTests,
7-
pytestCheckHook,
8-
pythonOlder,
97
setuptools,
108
twisted,
119
txamqp,
@@ -18,13 +16,17 @@ buildPythonPackage rec {
1816
version = "1.1.10";
1917
pyproject = true;
2018

21-
disabled = pythonOlder "3.10";
22-
2319
src = fetchPypi {
2420
inherit pname version;
2521
hash = "sha256-wTtbqRHMWBcM2iFN95yzwCf/BQ+EK0vp5MXT4mKX3lw=";
2622
};
2723

24+
patches = [
25+
# imp has been removed from python since version 3.12
26+
# This patch replaces it with distutils.utils
27+
./replace-imp.patch
28+
];
29+
2830
# Carbon-s default installation is /opt/graphite. This env variable ensures
2931
# carbon is installed as a regular Python module.
3032
GRAPHITE_NO_PREFIX = "True";
@@ -51,14 +53,17 @@ buildPythonPackage rec {
5153
inherit (nixosTests) graphite;
5254
};
5355

54-
pythonImportsCheck = [ "carbon" ];
56+
pythonImportsCheck = [
57+
"carbon"
58+
"carbon.routers"
59+
];
5560

56-
meta = with lib; {
61+
meta = {
5762
description = "Backend data caching and persistence daemon for Graphite";
5863
homepage = "https://github.com/graphite-project/carbon";
5964
changelog = "https://github.com/graphite-project/carbon/releases/tag/${version}";
60-
license = licenses.asl20;
61-
maintainers = with maintainers; [
65+
license = lib.licenses.asl20;
66+
maintainers = with lib.maintainers; [
6267
offline
6368
basvandijk
6469
];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/lib/carbon/routers.py b/lib/carbon/routers.py
2+
index d1c47b7..1a70d7e 100644
3+
--- a/lib/carbon/routers.py
4+
+++ b/lib/carbon/routers.py
5+
@@ -1,4 +1,4 @@
6+
-import imp
7+
+import importlib.util
8+
from carbon.hashing import ConsistentHashRing, carbonHash
9+
from carbon.util import PluginRegistrar
10+
from six import with_metaclass
11+
@@ -130,9 +130,8 @@ class ConsistentHashingRouter(DatapointRouter):
12+
13+
def setKeyFunctionFromModule(self, keyfunc_spec):
14+
module_path, func_name = keyfunc_spec.rsplit(':', 1)
15+
- module_file = open(module_path, 'U')
16+
- description = ('.py', 'U', imp.PY_SOURCE)
17+
- module = imp.load_module('keyfunc_module', module_file, module_path, description)
18+
+ spec = importlib.util.spec_from_file_location("keyfunc_module", module_path)
19+
+ module = importlib.util.module_from_spec(spec)
20+
keyfunc = getattr(module, func_name)
21+
self.setKeyFunction(keyfunc)
22+

0 commit comments

Comments
 (0)