diff --git a/pkgs/development/python-modules/django-prometheus/default.nix b/pkgs/development/python-modules/django-prometheus/default.nix new file mode 100644 index 000000000000..bd97f2a73614 --- /dev/null +++ b/pkgs/development/python-modules/django-prometheus/default.nix @@ -0,0 +1,52 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitHub +, prometheus-client +, psycopg2 +, pytest-django +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "django-prometheus"; + version = "2.1.0"; + format = "setuptools"; + disabled = pythonOlder "3.6"; + + src = fetchFromGitHub { + owner = "korfuri"; + repo = pname; + rev = version; + sha256 = "1y1cmycc545xrys41jk8kia36hwnkwhkw26mlpfdjgb63vq30x1d"; + }; + + patches = [ + ./drop-untestable-database-backends.patch + ]; + + postPatch = '' + substituteInPlace setup.py \ + --replace '"pytest-runner"' "" + ''; + + propagatedBuildInputs = [ + prometheus-client + ]; + + pythonImportsCheck = [ + "django_prometheus" + ]; + + checkInputs = [ + pytest-django + pytestCheckHook + ]; + + meta = with lib; { + description = "Django middlewares to monitor your application with Prometheus.io"; + homepage = "https://github.com/korfuri/django-prometheus"; + license = licenses.asl20; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/django-prometheus/drop-untestable-database-backends.patch b/pkgs/development/python-modules/django-prometheus/drop-untestable-database-backends.patch new file mode 100644 index 000000000000..1e9e65060849 --- /dev/null +++ b/pkgs/development/python-modules/django-prometheus/drop-untestable-database-backends.patch @@ -0,0 +1,38 @@ +diff --git a/django_prometheus/tests/end2end/testapp/settings.py b/django_prometheus/tests/end2end/testapp/settings.py +index 0630721..bd2190a 100644 +--- a/django_prometheus/tests/end2end/testapp/settings.py ++++ b/django_prometheus/tests/end2end/testapp/settings.py +@@ -53,33 +53,6 @@ DATABASES = { + "ENGINE": "django_prometheus.db.backends.sqlite3", + "NAME": "db.sqlite3", + }, +- # Comment this to not test django_prometheus.db.backends.postgres. +- "postgresql": { +- "ENGINE": "django_prometheus.db.backends.postgresql", +- "NAME": "postgres", +- "USER": "postgres", +- "PASSWORD": "", +- "HOST": "localhost", +- "PORT": "5432", +- }, +- # Comment this to not test django_prometheus.db.backends.postgis. +- "postgis": { +- "ENGINE": "django_prometheus.db.backends.postgis", +- "NAME": "postgis", +- "USER": "postgres", +- "PASSWORD": "", +- "HOST": "localhost", +- "PORT": "5432", +- }, +- # Comment this to not test django_prometheus.db.backends.mysql. +- "mysql": { +- "ENGINE": "django_prometheus.db.backends.mysql", +- "NAME": "django_prometheus_1", +- "USER": "travis", +- "PASSWORD": "", +- "HOST": "localhost", +- "PORT": "3306", +- }, + # The following databases are used by test_db.py only + "test_db_1": { + "ENGINE": "django_prometheus.db.backends.sqlite3", diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 6bbef5681fcf..805417f1321b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2169,6 +2169,8 @@ in { django-postgresql-netfields = callPackage ../development/python-modules/django-postgresql-netfields { }; + django-prometheus = callPackage ../development/python-modules/django-prometheus { }; + django-q = callPackage ../development/python-modules/django-q { }; djangoql = callPackage ../development/python-modules/djangoql { };