Skip to content

Commit 6209220

Browse files
authored
python312Packages.whisper: cleanup (#382964)
2 parents 360cd99 + c33668e commit 6209220

File tree

6 files changed

+166
-60
lines changed

6 files changed

+166
-60
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+

pkgs/development/python-modules/graphite-web/default.nix

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,61 @@
11
{
22
lib,
3+
stdenv,
4+
pkgs,
35
buildPythonPackage,
4-
python,
6+
fetchFromGitHub,
7+
8+
# dependencies
59
cairocffi,
610
django,
711
django-tagging,
8-
fetchFromGitHub,
9-
fetchpatch,
1012
gunicorn,
11-
mock,
1213
pyparsing,
1314
python-memcached,
14-
pythonOlder,
1515
pytz,
1616
six,
1717
txamqp,
1818
urllib3,
1919
whisper,
20+
21+
# tests
22+
mock,
23+
redis,
24+
rrdtool,
25+
writableTmpDirAsHomeHook,
26+
python,
27+
28+
# passthru
2029
nixosTests,
2130
}:
2231

23-
buildPythonPackage rec {
32+
buildPythonPackage {
2433
pname = "graphite-web";
25-
version = "1.1.10";
26-
format = "setuptools";
27-
28-
disabled = pythonOlder "3.7";
34+
version = "1.1.10-unstable-2025-02-24";
35+
pyproject = true;
2936

3037
src = fetchFromGitHub {
3138
owner = "graphite-project";
32-
repo = pname;
33-
rev = version;
34-
hash = "sha256-2HgCBKwLfxJLKMopoIdsEW5k/j3kNAiifWDnJ98a7Qo=";
39+
repo = "graphite-web";
40+
rev = "49c28e2015d605ad9ec93524f7076dd924a4731a";
41+
hash = "sha256-TxsQPhnI5WhQvKKkDEYZ8xnyg/qf+N9Icej6d6A0jC0=";
3542
};
3643

37-
patches = [
38-
(fetchpatch {
39-
name = "CVE-2022-4730.CVE-2022-4729.CVE-2022-4728.part-1.patch";
40-
url = "https://github.com/graphite-project/graphite-web/commit/9c626006eea36a9fd785e8f811359aebc9774970.patch";
41-
hash = "sha256-JMmdhLqsaRhUG2FsH+yPNl+cR7O2YLfKFliL2GU0aAk=";
42-
})
43-
(fetchpatch {
44-
name = "CVE-2022-4730.CVE-2022-4729.CVE-2022-4728.part-2.patch";
45-
url = "https://github.com/graphite-project/graphite-web/commit/2f178f490e10efc03cd1d27c72f64ecab224eb23.patch";
46-
hash = "sha256-NL7K5uekf3NlLa58aFFRPJT9ktjqBeNlWC4Htd0fRQ0=";
47-
})
48-
];
44+
postPatch =
45+
''
46+
substituteInPlace webapp/graphite/settings.py \
47+
--replace-fail \
48+
"join(WEBAPP_DIR, 'content')" \
49+
"join('$out/webapp', 'content')"
50+
''
51+
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
52+
substituteInPlace webapp/tests/test_dashboard.py \
53+
--replace-fail "test_dashboard_email" "_dont_test_dashboard_email"
54+
substituteInPlace webapp/tests/test_render.py \
55+
--replace-fail "test_render_view" "_dont_test_render_view"
56+
'';
4957

50-
propagatedBuildInputs = [
58+
dependencies = [
5159
cairocffi
5260
django
5361
django-tagging
@@ -61,49 +69,63 @@ buildPythonPackage rec {
6169
whisper
6270
];
6371

64-
postPatch = ''
65-
substituteInPlace setup.py \
66-
--replace "Django>=1.8,<3.1" "Django" \
67-
--replace "django-tagging==0.4.3" "django-tagging"
68-
'';
72+
pythonRelaxDeps = [
73+
"django"
74+
"django-tagging"
75+
];
6976

70-
# Carbon-s default installation is /opt/graphite. This env variable ensures
71-
# carbon is installed as a regular Python module.
72-
GRAPHITE_NO_PREFIX = "True";
77+
env = {
78+
# Carbon-s default installation is /opt/graphite. This env variable ensures
79+
# carbon is installed as a regular Python module.
80+
GRAPHITE_NO_PREFIX = "True";
7381

74-
preConfigure = ''
75-
substituteInPlace webapp/graphite/settings.py \
76-
--replace "join(WEBAPP_DIR, 'content')" "join('$out', 'webapp', 'content')"
77-
'';
82+
REDIS_HOST = "127.0.0.1";
83+
};
84+
85+
nativeCheckInputs = [
86+
mock
87+
redis
88+
rrdtool
89+
writableTmpDirAsHomeHook
90+
];
91+
92+
preCheck =
93+
# Start a redis server
94+
''
95+
${pkgs.valkey}/bin/redis-server &
96+
REDIS_PID=$!
97+
'';
7898

79-
checkInputs = [ mock ];
8099
checkPhase = ''
81100
runHook preCheck
82101
83102
pushd webapp/
84103
# avoid confusion with installed module
85104
rm -r graphite
86-
# redis not practical in test environment
87-
substituteInPlace tests/test_tags.py \
88-
--replace test_redis_tagdb _dont_test_redis_tagdb
89105
90106
DJANGO_SETTINGS_MODULE=tests.settings ${python.interpreter} manage.py test
91107
popd
92108
93109
runHook postCheck
94110
'';
95111

112+
postCheck = ''
113+
kill $REDIS_PID
114+
'';
115+
116+
__darwinAllowLocalNetworking = true;
117+
96118
pythonImportsCheck = [ "graphite" ];
97119

98120
passthru.tests = {
99121
inherit (nixosTests) graphite;
100122
};
101123

102-
meta = with lib; {
124+
meta = {
103125
description = "Enterprise scalable realtime graphing";
104126
homepage = "http://graphiteapp.org/";
105-
license = licenses.asl20;
106-
maintainers = with maintainers; [
127+
license = lib.licenses.asl20;
128+
maintainers = with lib.maintainers; [
107129
offline
108130
basvandijk
109131
];
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
lib,
3+
pkgs,
4+
buildPythonPackage,
5+
fetchFromGitHub,
6+
setuptools,
7+
pytestCheckHook,
8+
}:
9+
10+
buildPythonPackage rec {
11+
pname = "rrdtool";
12+
version = "0.1.16";
13+
pyproject = true;
14+
15+
src = fetchFromGitHub {
16+
owner = "commx";
17+
repo = "python-rrdtool";
18+
tag = "v${version}";
19+
hash = "sha256-xBMyY2/lY16H7D0JX5BhgHV5afDKKDObPJnynZ4iZdI=";
20+
};
21+
22+
build-system = [
23+
setuptools
24+
];
25+
26+
buildInputs = [
27+
pkgs.rrdtool
28+
];
29+
30+
env.NIX_CFLAGS_COMPILE = toString [
31+
"-Wno-error=implicit-function-declaration"
32+
"-Wno-error=incompatible-pointer-types"
33+
];
34+
35+
pythonImportsCheck = [ "rrdtool" ];
36+
37+
nativeCheckInputs = [
38+
pytestCheckHook
39+
];
40+
41+
__darwinAllowLocalNetworking = true;
42+
43+
meta = {
44+
description = "Python bindings for rrdtool";
45+
homepage = "https://github.com/commx/python-rrdtool";
46+
license = lib.licenses.lgpl21Only;
47+
maintainers = with lib.maintainers; [ GaetanLepage ];
48+
};
49+
}

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22
lib,
33
buildPythonPackage,
44
fetchFromGitHub,
5-
mock,
5+
setuptools,
66
six,
7+
mock,
78
pytestCheckHook,
89
}:
910

1011
buildPythonPackage rec {
1112
pname = "whisper";
1213
version = "1.1.10";
13-
format = "setuptools";
14+
pyproject = true;
1415

1516
src = fetchFromGitHub {
1617
owner = "graphite-project";
17-
repo = pname;
18+
repo = "whisper";
1819
tag = version;
1920
hash = "sha256-CnCbRmI2jc67mTtfupoE1uHtobrAiWoUXbfX8YeEV6A=";
2021
};
2122

22-
propagatedBuildInputs = [ six ];
23+
build-system = [ setuptools ];
24+
25+
dependencies = [ six ];
2326

2427
nativeCheckInputs = [
2528
mock
@@ -33,13 +36,16 @@ buildPythonPackage rec {
3336

3437
pythonImportsCheck = [ "whisper" ];
3538

36-
meta = with lib; {
39+
meta = {
3740
homepage = "https://github.com/graphite-project/whisper";
3841
description = "Fixed size round-robin style database";
39-
maintainers = with maintainers; [
42+
changelog = "https://graphite.readthedocs.io/en/latest/releases/${
43+
builtins.replaceStrings [ "." ] [ "_" ] version
44+
}.html";
45+
maintainers = with lib.maintainers; [
4046
offline
4147
basvandijk
4248
];
43-
license = licenses.asl20;
49+
license = lib.licenses.asl20;
4450
};
4551
}

pkgs/top-level/python-packages.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15083,6 +15083,8 @@ self: super: with self; {
1508315083

1508415084
rq = callPackage ../development/python-modules/rq { };
1508515085

15086+
rrdtool = callPackage ../development/python-modules/rrdtool { };
15087+
1508615088
rsa = callPackage ../development/python-modules/rsa { };
1508715089

1508815090
rsskey = callPackage ../development/python-modules/rsskey { };

0 commit comments

Comments
 (0)