From 47b475d33a8ce99f041c692b111ce72f4555b514 Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Wed, 9 Sep 2026 16:44:13 +0530 Subject: [PATCH] python3Packages.django-cacheops: fix and modernize Signed-off-by: phanirithvij --- .../Support-Python-3.14-pickle-changes.patch | 33 +++++++++++++++++++ .../django-cacheops/default.nix | 24 +++++++++----- 2 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/python-modules/django-cacheops/Support-Python-3.14-pickle-changes.patch diff --git a/pkgs/development/python-modules/django-cacheops/Support-Python-3.14-pickle-changes.patch b/pkgs/development/python-modules/django-cacheops/Support-Python-3.14-pickle-changes.patch new file mode 100644 index 000000000000..6dbd3584cd94 --- /dev/null +++ b/pkgs/development/python-modules/django-cacheops/Support-Python-3.14-pickle-changes.patch @@ -0,0 +1,33 @@ +From 938f8ba11c0676a1b9090c1cf788321ec24979e6 Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Fri, 29 May 2026 12:00:23 +1000 +Subject: [PATCH] Support Python 3.14 pickle changes + +pickle.dump() and friends in Python 3.14 will now raise PicklingError +rather than AttributeError when they encounter something that can not be +pickled, extend test_385 to handle both exceptions. +--- + tests/tests.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tests/tests.py b/tests/tests.py +index f99f8e26..5ad67a55 100644 +--- a/tests/tests.py ++++ b/tests/tests.py +@@ -2,6 +2,7 @@ + from functools import reduce + import operator + import re ++from pickle import PicklingError + import platform + import unittest + from unittest import mock +@@ -659,7 +660,7 @@ def test_366(self): + def test_385(self): + Client.objects.create(name='Client Name') + +- with self.assertRaisesRegex(AttributeError, "local object"): ++ with self.assertRaisesRegex((AttributeError, PicklingError), "local object"): + Client.objects.filter(name='Client Name').cache().first() + + invalidate_model(Client) diff --git a/pkgs/development/python-modules/django-cacheops/default.nix b/pkgs/development/python-modules/django-cacheops/default.nix index f0c7d41d02a5..e79a028654f5 100644 --- a/pkgs/development/python-modules/django-cacheops/default.nix +++ b/pkgs/development/python-modules/django-cacheops/default.nix @@ -1,7 +1,8 @@ { lib, buildPythonPackage, - fetchPypi, + fetchFromGitHub, + fetchpatch, django, funcy, redis, @@ -18,17 +19,24 @@ setuptools, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "django-cacheops"; version = "7.2"; pyproject = true; - src = fetchPypi { - pname = "django_cacheops"; - inherit version; - hash = "sha256-y8EcwDISlaNkTie8smlA8Iy5wucdPuUGy8/wvdoanzM="; + src = fetchFromGitHub { + owner = "Suor"; + repo = "django-cacheops"; + tag = finalAttrs.version; + hash = "sha256-o0QPBfoYZzBPMjDQt8ck2Tkx3qInyfnN88buire0yc4="; }; + patches = [ + # Fixes failure with python3.14 pickle changes + # https://github.com/Suor/django-cacheops/pull/511 + ./Support-Python-3.14-pickle-changes.patch + ]; + pythonRelaxDeps = [ "funcy" ]; build-system = [ setuptools ]; @@ -59,8 +67,8 @@ buildPythonPackage rec { meta = { description = "Slick ORM cache with automatic granular event-driven invalidation for Django"; homepage = "https://github.com/Suor/django-cacheops"; - changelog = "https://github.com/Suor/django-cacheops/blob/${version}/CHANGELOG"; + changelog = "https://github.com/Suor/django-cacheops/blob/${finalAttrs.version}/CHANGELOG"; license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ onny ]; }; -} +})