Merge pull request #258907 from mweinelt/django-5.0a1

python311Packages.django_5: init at 5.0a1
This commit is contained in:
Martin Weinelt 2023-10-23 01:37:57 +02:00 committed by GitHub
commit 9561cb0115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 219 additions and 0 deletions

View file

@ -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 ];
};
}

View file

@ -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"):

View file

@ -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:

View file

@ -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)

View file

@ -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"] = ""

View file

@ -2887,6 +2887,9 @@ self: super: with self; {
django = self.django_4; django = self.django_4;
django_4 = callPackage ../development/python-modules/django/4.nix { }; 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-datta = callPackage ../development/python-modules/django-admin-datta { };
django-admin-sortable2 = callPackage ../development/python-modules/django-admin-sortable2 { }; django-admin-sortable2 = callPackage ../development/python-modules/django-admin-sortable2 { };