summary refs log tree commit diff
diff options
context:
space:
mode:
authorMartin Weinelt <hexa@darmstadt.ccc.de>2023-10-04 04:27:25 +0200
committerMartin Weinelt <hexa@darmstadt.ccc.de>2023-10-04 04:28:20 +0200
commit92e63fc23260e9dcedb269472585a82a888df9d8 (patch)
tree3f77895d899d8cd3f5fb7329cb753b20ed20689d
parenta280ee5731306413016b44591919a10ed5241378 (diff)
downloadnixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.tar
nixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.tar.gz
nixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.tar.bz2
nixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.tar.lz
nixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.tar.xz
nixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.tar.zst
nixpkgs-92e63fc23260e9dcedb269472585a82a888df9d8.zip
python311Packages.django_5: init at 5.0a1
https://www.djangoproject.com/weblog/2023/sep/18/django-50-alpha-1-released/
https://docs.djangoproject.com/en/dev/releases/5.0/
-rw-r--r--pkgs/development/python-modules/django/5.nix144
-rw-r--r--pkgs/development/python-modules/django/django_5_disable_failing_tests.patch21
-rw-r--r--pkgs/development/python-modules/django/django_5_set_geos_gdal_lib.patch26
-rw-r--r--pkgs/development/python-modules/django/django_5_set_zoneinfo_dir.patch13
-rw-r--r--pkgs/development/python-modules/django/django_5_tests_pythonpath.patch12
-rw-r--r--pkgs/top-level/python-packages.nix3
6 files changed, 219 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/django/5.nix b/pkgs/development/python-modules/django/5.nix
new file mode 100644
index 00000000000..f17a961db65
--- /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.0a1";
+  pyproject = true;
+
+  disabled = pythonOlder "3.10";
+
+  src = fetchPypi {
+    inherit pname version;
+    hash = "sha256-OlIFL7xeAfIgLAIKgkGqQNwDCxbI+0ncSAzEarhzUVg=";
+  };
+
+  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"] = ""
+ 
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index a3e8bb1255b..48ac150f81c 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -2860,6 +2860,9 @@ self: super: with self; {
   django = self.django_4;
   django_4 = callPackage ../development/python-modules/django/4.nix { };
 
+  # Pre-release
+  django_5 = callPackage ../development/python-modules/django/5.nix { };
+
   django-admin-datta = callPackage ../development/python-modules/django-admin-datta { };
 
   django-admin-sortable2 = callPackage ../development/python-modules/django-admin-sortable2 { };