Unverified Commit cbda4e87 authored by Martin Weinelt's avatar Martin Weinelt
Browse files

python3Packages.django_4: drop

Removing due to it becoming a leaf package right before it's EOL on April
30th.

Closes: #490868
parent 82839c1e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
  pytestCheckHook,
  # for passthru.tests
  asyncssh,
  django_4,
  django,
  fastapi,
  paramiko,
  twisted,
@@ -57,7 +57,7 @@ buildPythonPackage rec {
  passthru.tests = {
    inherit
      asyncssh
      django_4
      django
      fastapi
      paramiko
      twisted
+0 −174
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  pythonAtLeast,
  replaceVars,

  # 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 = "4.2.29";
  pyproject = true;

  disabled = pythonAtLeast "3.13";

  src = fetchFromGitHub {
    owner = "django";
    repo = "django";
    tag = version;
    hash = "sha256-30OcLxtACSxLJ1jT+k7fmM8CyMyleXSPc+l7/3JZKzI=";
  };

  patches = [
    (replaceVars ./django_4_set_zoneinfo_dir.patch {
      zoneinfo = tzdata + "/share/zoneinfo";
    })
    # make sure the tests don't remove packages from our pythonpath
    # and disable failing tests
    ./django_4_tests.patch

    # fix filename length limit tests on bcachefs
    # FIXME: remove if ever backported
    (fetchpatch {
      url = "https://github.com/django/django/commit/12f4f95405c7857cbf2f4bf4d0261154aac31676.patch";
      hash = "sha256-+K20/V8sh036Ox9U7CSPgfxue7f28Sdhr3MsB7erVOk=";
    })

    # backport fix for https://code.djangoproject.com/ticket/36056
    # FIXME: remove if ever backported upstream
    (fetchpatch {
      url = "https://github.com/django/django/commit/ec0e784f91b551c654f0962431cc31091926792d.patch";
      includes = [ "django/*" ]; # tests don't apply
      hash = "sha256-8YwdOBNJq6+GNoxzdLyN9HEEIWRXGQk9YbyfPwYVkwU=";
    })

  ]
  ++ lib.optionals withGdal [
    (replaceVars ./django_4_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}"
  ''
  + lib.optionalString (pythonAtLeast "3.12" && stdenv.hostPlatform.system == "aarch64-linux") ''
    # Test regression after xz was reverted from 5.6.0 to 5.4.6
    # https://hydra.nixos.org/build/254630990
    substituteInPlace tests/view_tests/tests/test_debug.py \
      --replace-fail "test_files" "dont_test_files"
  ''
  + lib.optionalString (pythonAtLeast "3.13") ''
    # Fixed CommandTypes.test_help_default_options_with_custom_arguments test on Python 3.13+.
    # https://github.com/django/django/commit/3426a5c33c36266af42128ee9eca4921e68ea876
    substituteInPlace tests/admin_scripts/tests.py --replace-fail \
      "test_help_default_options_with_custom_arguments" \
      "dont_test_help_default_options_with_custom_arguments"
  '';

  nativeBuildInputs = [ setuptools ];

  propagatedBuildInputs = [
    asgiref
    sqlparse
  ];

  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.concatAttrValues optional-dependencies;

  doCheck =
    !stdenv.hostPlatform.isDarwin
    # pywatchman depends on folly which does not support 32bits
    && !stdenv.hostPlatform.is32bit;

  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 = {
    changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor version}/releases/${version}/";
    description = "High-level Python Web framework that encourages rapid development and clean, pragmatic design";
    mainProgram = "django-admin";
    homepage = "https://www.djangoproject.com";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ hexa ];
  };
}
+0 −26
Original line number Diff line number Diff line
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index 05b5732..91fafee 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -14,7 +14,7 @@ try:
     from django.conf import settings
     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 2cdb5d3..fac2d04 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -24,7 +24,7 @@ def load_geos():
         from django.conf import settings
         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:
+0 −13
Original line number Diff line number Diff line
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index cb70a71791..5156f7dd73 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -227,7 +227,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)
+0 −51
Original line number Diff line number Diff line
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 6d67c2931a..0c1f407f88 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -127,6 +127,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/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py
index 36f22d5f09..6cc6888980 100644
--- a/tests/auth_tests/test_hashers.py
+++ b/tests/auth_tests/test_hashers.py
@@ -1,4 +1,4 @@
-from unittest import mock, skipUnless
+from unittest import mock, skipUnless, skip
 
 from django.conf.global_settings import PASSWORD_HASHERS
 from django.contrib.auth.hashers import (
@@ -241,6 +241,7 @@ class TestUtilsHashPass(SimpleTestCase):
 
     @ignore_warnings(category=RemovedInDjango50Warning)
     @skipUnless(crypt, "no crypt module to generate password.")
+    @skip("Legacy crypt algorithms are unsupported in nixpkgs")
     @override_settings(
         PASSWORD_HASHERS=["django.contrib.auth.hashers.CryptPasswordHasher"]
     )
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
index 62cbffbee9..2f0ec718f8 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,
@@ -342,6 +342,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"):
Loading