From 8fb44a4928fbeda9b38d81108fca25b04418d309 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Fri, 9 Jun 2023 18:23:03 +0200 Subject: [PATCH] python3Packages.django-cachalot: init at 2.5.3 --- .../django-cachalot/default.nix | 54 +++++++++++++++ .../disable-unsupported-tests.patch | 65 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 121 insertions(+) create mode 100644 pkgs/development/python-modules/django-cachalot/default.nix create mode 100644 pkgs/development/python-modules/django-cachalot/disable-unsupported-tests.patch diff --git a/pkgs/development/python-modules/django-cachalot/default.nix b/pkgs/development/python-modules/django-cachalot/default.nix new file mode 100644 index 000000000000..f52a3aa46e62 --- /dev/null +++ b/pkgs/development/python-modules/django-cachalot/default.nix @@ -0,0 +1,54 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, django +, django-debug-toolbar +, psycopg2 +, beautifulsoup4 +, python +}: + +buildPythonPackage rec { + pname = "django-cachalot"; + version = "2.5.3"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "noripyt"; + repo = "django-cachalot"; + rev = "v${version}"; + hash = "sha256-ayAN+PgK3aIpt4R8aeC6c6mRGTnfObycmkoXPTjx4WI="; + }; + + patches = [ + # Disable tests for unsupported caching and database types which would + # require additional running backends + ./disable-unsupported-tests.patch + ]; + + propagatedBuildInputs = [ + django + ]; + + checkInputs = [ + beautifulsoup4 + django-debug-toolbar + psycopg2 + ]; + + pythonImportsCheck = [ "cachalot" ]; + + checkPhase = '' + runHook preCheck + ${python.interpreter} runtests.py + runHook postCheck + ''; + + meta = with lib; { + description = "No effort, no worry, maximum performance"; + homepage = "https://github.com/noripyt/django-cachalot"; + changelog = "https://github.com/noripyt/django-cachalot/blob/${src.rev}/CHANGELOG.rst"; + license = licenses.bsd3; + maintainers = with maintainers; [ onny ]; + }; +} diff --git a/pkgs/development/python-modules/django-cachalot/disable-unsupported-tests.patch b/pkgs/development/python-modules/django-cachalot/disable-unsupported-tests.patch new file mode 100644 index 000000000000..8683fffbb146 --- /dev/null +++ b/pkgs/development/python-modules/django-cachalot/disable-unsupported-tests.patch @@ -0,0 +1,65 @@ +diff --git a/cachalot/tests/models.py b/cachalot/tests/models.py +index 8c48640..817602c 100644 +--- a/cachalot/tests/models.py ++++ b/cachalot/tests/models.py +@@ -77,11 +77,6 @@ class PostgresModel(Model): + date_range = DateRangeField(null=True, blank=True) + datetime_range = DateTimeRangeField(null=True, blank=True) + +- class Meta: +- # Tests schema name in table name. +- db_table = '"public"."cachalot_postgresmodel"' +- +- + class UnmanagedModel(Model): + name = CharField(max_length=50) + +diff --git a/settings.py b/settings.py +index 19d7560..7095367 100644 +--- a/settings.py ++++ b/settings.py +@@ -8,18 +8,9 @@ DATABASES = { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'cachalot.sqlite3', + }, +- 'postgresql': { +- 'ENGINE': 'django.db.backends.postgresql', +- 'NAME': 'cachalot', +- 'USER': 'cachalot', +- 'PASSWORD': 'password', +- 'HOST': '127.0.0.1', +- }, +- 'mysql': { +- 'ENGINE': 'django.db.backends.mysql', +- 'NAME': 'cachalot', +- 'USER': 'root', +- 'HOST': '127.0.0.1', ++ 'test': { ++ 'ENGINE': 'django.db.backends.sqlite3', ++ 'NAME': ':memory:', + }, + } + if 'MYSQL_PASSWORD' in os.environ: +@@ -36,22 +27,6 @@ DEFAULT_AUTO_FIELD = "django.db.models.AutoField" + DATABASE_ROUTERS = ['cachalot.tests.db_router.PostgresRouter'] + + CACHES = { +- 'redis': { +- 'BACKEND': 'django_redis.cache.RedisCache', +- 'LOCATION': 'redis://127.0.0.1:6379/0', +- 'OPTIONS': { +- # Since we are using both Python 2 & 3 in tests, we need to use +- # a compatible pickle version to avoid unpickling errors when +- # running a Python 2 test after a Python 3 test. +- 'PICKLE_VERSION': 2, +- }, +- }, +- 'memcached': { +- 'BACKEND': 'django.core.cache.backends.memcached.' +- + ('PyMemcacheCache' if __DJ_V[0] > 2 +- and (__DJ_V[1] > 1 or __DJ_V[0] > 3) else 'MemcachedCache'), +- 'LOCATION': '127.0.0.1:11211', +- }, + 'locmem': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'OPTIONS': { diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c9abde7c8336..e4a50cbc6b85 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2699,6 +2699,8 @@ self: super: with self; { django-bootstrap4 = callPackage ../development/python-modules/django-bootstrap4 { }; + django-cachalot = callPackage ../development/python-modules/django-cachalot { }; + django-cache-url = callPackage ../development/python-modules/django-cache-url { }; django-cacheops = callPackage ../development/python-modules/django-cacheops { };