Unverified Commit 6209220c authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

python312Packages.whisper: cleanup (#382964)

parents 360cd99e c33668e2
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -4,8 +4,6 @@
  cachetools,
  fetchPypi,
  nixosTests,
  pytestCheckHook,
  pythonOlder,
  setuptools,
  twisted,
  txamqp,
@@ -18,13 +16,17 @@ buildPythonPackage rec {
  version = "1.1.10";
  pyproject = true;

  disabled = pythonOlder "3.10";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-wTtbqRHMWBcM2iFN95yzwCf/BQ+EK0vp5MXT4mKX3lw=";
  };

  patches = [
    # imp has been removed from python since version 3.12
    # This patch replaces it with distutils.utils
    ./replace-imp.patch
  ];

  # Carbon-s default installation is /opt/graphite. This env variable ensures
  # carbon is installed as a regular Python module.
  GRAPHITE_NO_PREFIX = "True";
@@ -51,14 +53,17 @@ buildPythonPackage rec {
    inherit (nixosTests) graphite;
  };

  pythonImportsCheck = [ "carbon" ];
  pythonImportsCheck = [
    "carbon"
    "carbon.routers"
  ];

  meta = with lib; {
  meta = {
    description = "Backend data caching and persistence daemon for Graphite";
    homepage = "https://github.com/graphite-project/carbon";
    changelog = "https://github.com/graphite-project/carbon/releases/tag/${version}";
    license = licenses.asl20;
    maintainers = with maintainers; [
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      offline
      basvandijk
    ];
+22 −0
Original line number Diff line number Diff line
diff --git a/lib/carbon/routers.py b/lib/carbon/routers.py
index d1c47b7..1a70d7e 100644
--- a/lib/carbon/routers.py
+++ b/lib/carbon/routers.py
@@ -1,4 +1,4 @@
-import imp
+import importlib.util
 from carbon.hashing import ConsistentHashRing, carbonHash
 from carbon.util import PluginRegistrar
 from six import with_metaclass
@@ -130,9 +130,8 @@ class ConsistentHashingRouter(DatapointRouter):
 
   def setKeyFunctionFromModule(self, keyfunc_spec):
     module_path, func_name = keyfunc_spec.rsplit(':', 1)
-    module_file = open(module_path, 'U')
-    description = ('.py', 'U', imp.PY_SOURCE)
-    module = imp.load_module('keyfunc_module', module_file, module_path, description)
+    spec = importlib.util.spec_from_file_location("keyfunc_module", module_path)
+    module = importlib.util.module_from_spec(spec)
     keyfunc = getattr(module, func_name)
     self.setKeyFunction(keyfunc)
 
+67 −45
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  pkgs,
  buildPythonPackage,
  python,
  fetchFromGitHub,

  # dependencies
  cairocffi,
  django,
  django-tagging,
  fetchFromGitHub,
  fetchpatch,
  gunicorn,
  mock,
  pyparsing,
  python-memcached,
  pythonOlder,
  pytz,
  six,
  txamqp,
  urllib3,
  whisper,

  # tests
  mock,
  redis,
  rrdtool,
  writableTmpDirAsHomeHook,
  python,

  # passthru
  nixosTests,
}:

buildPythonPackage rec {
buildPythonPackage {
  pname = "graphite-web";
  version = "1.1.10";
  format = "setuptools";

  disabled = pythonOlder "3.7";
  version = "1.1.10-unstable-2025-02-24";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "graphite-project";
    repo = pname;
    rev = version;
    hash = "sha256-2HgCBKwLfxJLKMopoIdsEW5k/j3kNAiifWDnJ98a7Qo=";
    repo = "graphite-web";
    rev = "49c28e2015d605ad9ec93524f7076dd924a4731a";
    hash = "sha256-TxsQPhnI5WhQvKKkDEYZ8xnyg/qf+N9Icej6d6A0jC0=";
  };

  patches = [
    (fetchpatch {
      name = "CVE-2022-4730.CVE-2022-4729.CVE-2022-4728.part-1.patch";
      url = "https://github.com/graphite-project/graphite-web/commit/9c626006eea36a9fd785e8f811359aebc9774970.patch";
      hash = "sha256-JMmdhLqsaRhUG2FsH+yPNl+cR7O2YLfKFliL2GU0aAk=";
    })
    (fetchpatch {
      name = "CVE-2022-4730.CVE-2022-4729.CVE-2022-4728.part-2.patch";
      url = "https://github.com/graphite-project/graphite-web/commit/2f178f490e10efc03cd1d27c72f64ecab224eb23.patch";
      hash = "sha256-NL7K5uekf3NlLa58aFFRPJT9ktjqBeNlWC4Htd0fRQ0=";
    })
  ];
  postPatch =
    ''
      substituteInPlace webapp/graphite/settings.py \
        --replace-fail \
          "join(WEBAPP_DIR, 'content')" \
          "join('$out/webapp', 'content')"
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      substituteInPlace webapp/tests/test_dashboard.py \
        --replace-fail "test_dashboard_email" "_dont_test_dashboard_email"
      substituteInPlace webapp/tests/test_render.py \
        --replace-fail "test_render_view" "_dont_test_render_view"
    '';

  propagatedBuildInputs = [
  dependencies = [
    cairocffi
    django
    django-tagging
@@ -61,31 +69,39 @@ buildPythonPackage rec {
    whisper
  ];

  postPatch = ''
    substituteInPlace setup.py \
      --replace "Django>=1.8,<3.1" "Django" \
      --replace "django-tagging==0.4.3" "django-tagging"
  '';
  pythonRelaxDeps = [
    "django"
    "django-tagging"
  ];

  env = {
    # Carbon-s default installation is /opt/graphite. This env variable ensures
    # carbon is installed as a regular Python module.
    GRAPHITE_NO_PREFIX = "True";

  preConfigure = ''
    substituteInPlace webapp/graphite/settings.py \
      --replace "join(WEBAPP_DIR, 'content')" "join('$out', 'webapp', 'content')"
    REDIS_HOST = "127.0.0.1";
  };

  nativeCheckInputs = [
    mock
    redis
    rrdtool
    writableTmpDirAsHomeHook
  ];

  preCheck =
    # Start a redis server
    ''
      ${pkgs.valkey}/bin/redis-server &
      REDIS_PID=$!
    '';

  checkInputs = [ mock ];
  checkPhase = ''
    runHook preCheck

    pushd webapp/
    # avoid confusion with installed module
    rm -r graphite
    # redis not practical in test environment
    substituteInPlace tests/test_tags.py \
      --replace test_redis_tagdb _dont_test_redis_tagdb

    DJANGO_SETTINGS_MODULE=tests.settings ${python.interpreter} manage.py test
    popd
@@ -93,17 +109,23 @@ buildPythonPackage rec {
    runHook postCheck
  '';

  postCheck = ''
    kill $REDIS_PID
  '';

  __darwinAllowLocalNetworking = true;

  pythonImportsCheck = [ "graphite" ];

  passthru.tests = {
    inherit (nixosTests) graphite;
  };

  meta = with lib; {
  meta = {
    description = "Enterprise scalable realtime graphing";
    homepage = "http://graphiteapp.org/";
    license = licenses.asl20;
    maintainers = with maintainers; [
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      offline
      basvandijk
    ];
+49 −0
Original line number Diff line number Diff line
{
  lib,
  pkgs,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "rrdtool";
  version = "0.1.16";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "commx";
    repo = "python-rrdtool";
    tag = "v${version}";
    hash = "sha256-xBMyY2/lY16H7D0JX5BhgHV5afDKKDObPJnynZ4iZdI=";
  };

  build-system = [
    setuptools
  ];

  buildInputs = [
    pkgs.rrdtool
  ];

  env.NIX_CFLAGS_COMPILE = toString [
    "-Wno-error=implicit-function-declaration"
    "-Wno-error=incompatible-pointer-types"
  ];

  pythonImportsCheck = [ "rrdtool" ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  __darwinAllowLocalNetworking = true;

  meta = {
    description = "Python bindings for rrdtool";
    homepage = "https://github.com/commx/python-rrdtool";
    license = lib.licenses.lgpl21Only;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
}
+13 −7
Original line number Diff line number Diff line
@@ -2,24 +2,27 @@
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  mock,
  setuptools,
  six,
  mock,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "whisper";
  version = "1.1.10";
  format = "setuptools";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "graphite-project";
    repo = pname;
    repo = "whisper";
    tag = version;
    hash = "sha256-CnCbRmI2jc67mTtfupoE1uHtobrAiWoUXbfX8YeEV6A=";
  };

  propagatedBuildInputs = [ six ];
  build-system = [ setuptools ];

  dependencies = [ six ];

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

  pythonImportsCheck = [ "whisper" ];

  meta = with lib; {
  meta = {
    homepage = "https://github.com/graphite-project/whisper";
    description = "Fixed size round-robin style database";
    maintainers = with maintainers; [
    changelog = "https://graphite.readthedocs.io/en/latest/releases/${
      builtins.replaceStrings [ "." ] [ "_" ] version
    }.html";
    maintainers = with lib.maintainers; [
      offline
      basvandijk
    ];
    license = licenses.asl20;
    license = lib.licenses.asl20;
  };
}
Loading