diff options
Diffstat (limited to 'pkgs/development/python-modules/django')
7 files changed, 220 insertions, 4 deletions
diff --git a/pkgs/development/python-modules/django/3.nix b/pkgs/development/python-modules/django/3.nix index 9c8e1384242..077ea73bd8b 100644 --- a/pkgs/development/python-modules/django/3.nix +++ b/pkgs/development/python-modules/django/3.nix @@ -15,14 +15,14 @@ buildPythonPackage rec { pname = "django"; - version = "3.2.20"; + version = "3.2.23"; disabled = pythonOlder "3.7"; src = fetchPypi { pname = "Django"; inherit version; - hash = "sha256-3sKhFnh7jhSWIBS/eOEgu6RUE1EI4a+em5Gt57KWTEA="; + hash = "sha256-gpaPNkDinvSnc68sKESPX3oI0AHGrAWzLQKu7mUJUIs="; }; patches = [ diff --git a/pkgs/development/python-modules/django/4.nix b/pkgs/development/python-modules/django/4.nix index c3df9cf4aef..69c438739f2 100644 --- a/pkgs/development/python-modules/django/4.nix +++ b/pkgs/development/python-modules/django/4.nix @@ -42,14 +42,14 @@ buildPythonPackage rec { pname = "Django"; - version = "4.2.4"; + version = "4.2.7"; format = "pyproject"; disabled = pythonOlder "3.10"; src = fetchPypi { inherit pname version; - hash = "sha256-fkIl7AZeDzVMz3NJoi0gneCcwcB0gyvp64TFHBeZxDI="; + hash = "sha256-jg8cLCeGtcDjn+GvziTJJgQPrUfI6orTCq8RiN8p/EE="; }; patches = [ diff --git a/pkgs/development/python-modules/django/5.nix b/pkgs/development/python-modules/django/5.nix new file mode 100644 index 00000000000..0ea8de9a4c7 --- /dev/null +++ b/pkgs/development/python-modules/django/5.nix @@ -0,0 +1,144 @@ +{ lib +, stdenv +, buildPythonPackage +, fetchPypi +, pythonOlder +, substituteAll + +# build +, setuptools + +# patched in +, geos +, gdal +, withGdal ? false + +# propagates +, asgiref +, sqlparse + +# extras +, argon2-cffi +, bcrypt + +# tests +, aiosmtpd +, docutils +, geoip2 +, jinja2 +, numpy +, pillow +, pylibmc +, pymemcache +, python +, pywatchman +, pyyaml +, pytz +, redis +, selenium +, tblib +, tzdata +}: + +buildPythonPackage rec { + pname = "Django"; + version = "5.0b1"; + pyproject = true; + + disabled = pythonOlder "3.10"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-yIY15zPwoO9GwhljXiHI9ZeOsqFMORgiRlRUG8XVcDA="; + }; + + patches = [ + (substituteAll { + src = ./django_5_set_zoneinfo_dir.patch; + zoneinfo = tzdata + "/share/zoneinfo"; + }) + # prevent tests from messing with our pythonpath + ./django_5_tests_pythonpath.patch + # disable test that excpects timezone issues + ./django_5_disable_failing_tests.patch + ] ++ lib.optionals withGdal [ + (substituteAll { + src = ./django_5_set_geos_gdal_lib.patch; + geos = geos; + gdal = gdal; + extension = stdenv.hostPlatform.extensions.sharedLibrary; + }) + ]; + + postPatch = '' + substituteInPlace tests/utils_tests/test_autoreload.py \ + --replace "/usr/bin/python" "${python.interpreter}" + ''; + + nativeBuildInputs = [ + setuptools + ]; + + propagatedBuildInputs = [ + asgiref + sqlparse + ]; + + passthru.optional-dependencies = { + argon2 = [ + argon2-cffi + ]; + bcrypt = [ + bcrypt + ]; + }; + + nativeCheckInputs = [ + # tests/requirements/py3.txt + aiosmtpd + docutils + geoip2 + jinja2 + numpy + pillow + pylibmc + pymemcache + pywatchman + pyyaml + pytz + redis + selenium + tblib + tzdata + ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies); + + doCheck = !stdenv.isDarwin; + + preCheck = '' + # make sure the installed library gets imported + rm -rf django + + # provide timezone data, works only on linux + export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo + ''; + + checkPhase = '' + runHook preCheck + + pushd tests + ${python.interpreter} runtests.py --settings=test_sqlite + popd + + runHook postCheck + ''; + + __darwinAllowLocalNetworking = true; + + meta = with lib; { + changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor version}/releases/${version}/"; + description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design."; + homepage = "https://www.djangoproject.com"; + license = licenses.bsd3; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/django/django_5_disable_failing_tests.patch b/pkgs/development/python-modules/django/django_5_disable_failing_tests.patch new file mode 100644 index 00000000000..dd4b3f6ac72 --- /dev/null +++ b/pkgs/development/python-modules/django/django_5_disable_failing_tests.patch @@ -0,0 +1,21 @@ +diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py +index b204487..243f060 100644 +--- a/tests/settings_tests/tests.py ++++ b/tests/settings_tests/tests.py +@@ -2,7 +2,7 @@ import os + import sys + import unittest + from types import ModuleType, SimpleNamespace +-from unittest import mock ++from unittest import mock, skip + + from django.conf import ENVIRONMENT_VARIABLE, LazySettings, Settings, settings + from django.core.exceptions import ImproperlyConfigured +@@ -335,6 +335,7 @@ class SettingsTests(SimpleTestCase): + getattr(s, "foo") + + @requires_tz_support ++ @skip("Assertion fails, exception does not get raised") + @mock.patch("django.conf.global_settings.TIME_ZONE", "test") + def test_incorrect_timezone(self): + with self.assertRaisesMessage(ValueError, "Incorrect timezone setting: test"): diff --git a/pkgs/development/python-modules/django/django_5_set_geos_gdal_lib.patch b/pkgs/development/python-modules/django/django_5_set_geos_gdal_lib.patch new file mode 100644 index 00000000000..c1fdcdc4e92 --- /dev/null +++ b/pkgs/development/python-modules/django/django_5_set_geos_gdal_lib.patch @@ -0,0 +1,26 @@ +diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py +index 30cba0f..5afc031 100644 +--- a/django/contrib/gis/gdal/libgdal.py ++++ b/django/contrib/gis/gdal/libgdal.py +@@ -15,7 +15,7 @@ try: + + lib_path = settings.GDAL_LIBRARY_PATH + except (AttributeError, ImportError, ImproperlyConfigured, OSError): +- lib_path = None ++ lib_path = "@gdal@/lib/libgdal@extension@" + + if lib_path: + lib_names = None +diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py +index 1121b4f..f14ea2f 100644 +--- a/django/contrib/gis/geos/libgeos.py ++++ b/django/contrib/gis/geos/libgeos.py +@@ -25,7 +25,7 @@ def load_geos(): + + lib_path = settings.GEOS_LIBRARY_PATH + except (AttributeError, ImportError, ImproperlyConfigured, OSError): +- lib_path = None ++ lib_path = "@geos@/lib/libgeos_c@extension@" + + # Setting the appropriate names for the GEOS-C library. + if lib_path: diff --git a/pkgs/development/python-modules/django/django_5_set_zoneinfo_dir.patch b/pkgs/development/python-modules/django/django_5_set_zoneinfo_dir.patch new file mode 100644 index 00000000000..166cc56281c --- /dev/null +++ b/pkgs/development/python-modules/django/django_5_set_zoneinfo_dir.patch @@ -0,0 +1,13 @@ +diff --git a/django/conf/__init__.py b/django/conf/__init__.py +index 22f1eab..3a752d1 100644 +--- a/django/conf/__init__.py ++++ b/django/conf/__init__.py +@@ -208,7 +208,7 @@ class Settings: + if hasattr(time, "tzset") and self.TIME_ZONE: + # When we can, attempt to validate the timezone. If we can't find + # this file, no check happens and it's harmless. +- zoneinfo_root = Path("/usr/share/zoneinfo") ++ zoneinfo_root = Path("@zoneinfo@") + zone_info_file = zoneinfo_root.joinpath(*self.TIME_ZONE.split("/")) + if zoneinfo_root.exists() and not zone_info_file.exists(): + raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE) diff --git a/pkgs/development/python-modules/django/django_5_tests_pythonpath.patch b/pkgs/development/python-modules/django/django_5_tests_pythonpath.patch new file mode 100644 index 00000000000..8355d267a73 --- /dev/null +++ b/pkgs/development/python-modules/django/django_5_tests_pythonpath.patch @@ -0,0 +1,12 @@ +diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py +index 7f39d7f..b5b0ae7 100644 +--- a/tests/admin_scripts/tests.py ++++ b/tests/admin_scripts/tests.py +@@ -126,6 +126,7 @@ class AdminScriptTestCase(SimpleTestCase): + del test_environ["DJANGO_SETTINGS_MODULE"] + python_path = [base_dir, django_dir, tests_dir] + python_path.extend(ext_backend_base_dirs) ++ python_path.extend(sys.path) + test_environ["PYTHONPATH"] = os.pathsep.join(python_path) + test_environ["PYTHONWARNINGS"] = "" + |