python3.pkgs.django: init at 4.2.9 from nixpkgs

This commit is contained in:
Milan Hauth 2024-02-03 15:27:55 +01:00
parent e18cef4020
commit ac1072ed0a
13 changed files with 554 additions and 0 deletions

View File

@ -326,6 +326,16 @@ pkgs.lib.makeScope pkgs.newScope (self: let inherit (self) callPackage; in rec {
crx3 = callPackage ./pkgs/python3/pkgs/crx3/crx3.nix { };
# LTS in extended support phase
django_3 = callPackage ./pkgs/development/python-modules/django/3.nix { };
# LTS with mainsteam support
django = self.django_4;
django_4 = callPackage ./pkgs/development/python-modules/django/4.nix { };
# Pre-release
django_5 = callPackage ./pkgs/development/python-modules/django/5.nix { };
#}))); # python3.pkgs
#}))); # python3

View File

@ -0,0 +1,58 @@
{ lib
, stdenv
, buildPythonPackage
, fetchPypi
, substituteAll
, geos_3_9
, gdal
, asgiref
, pytz
, sqlparse
, tzdata
, pythonOlder
, withGdal ? false
}:
buildPythonPackage rec {
pname = "django";
version = "3.2.23";
disabled = pythonOlder "3.7";
src = fetchPypi {
pname = "Django";
inherit version;
hash = "sha256-gpaPNkDinvSnc68sKESPX3oI0AHGrAWzLQKu7mUJUIs=";
};
patches = [
(substituteAll {
src = ./django_3_set_zoneinfo_dir.patch;
zoneinfo = tzdata + "/share/zoneinfo";
})
] ++ lib.optional withGdal
(substituteAll {
src = ./django_3_set_geos_gdal_lib.patch;
inherit geos_3_9;
inherit gdal;
extension = stdenv.hostPlatform.extensions.sharedLibrary;
});
propagatedBuildInputs = [
asgiref
pytz
sqlparse
];
# too complicated to setup
doCheck = false;
pythonImportsCheck = [ "django" ];
meta = with lib; {
description = "A high-level Python Web framework";
homepage = "https://www.djangoproject.com/";
license = licenses.bsd3;
maintainers = with maintainers; [ georgewhewell ];
};
}

View File

@ -0,0 +1,143 @@
{ 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 = "4.2.9";
format = "pyproject";
disabled = pythonOlder "3.8";
src = fetchPypi {
inherit pname version;
hash = "sha256-EkmMw8uLyAOFOf756Q6V9QdQJDbB8MOmc0ETJPpnXRQ=";
};
patches = [
(substituteAll {
src = ./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
] ++ lib.optionals withGdal [
(substituteAll {
src = ./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}"
'';
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,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.0.1";
pyproject = true;
disabled = pythonOlder "3.10";
src = fetchPypi {
inherit pname version;
hash = "sha256-jIZZZlvG46RP7+GrCikeWj+zl5+agjC+Kd6XXlfo+FQ=";
};
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,24 @@
diff -Nur a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
--- a/django/contrib/gis/gdal/libgdal.py 2020-07-09 22:34:05.330568948 +0100
+++ b/django/contrib/gis/gdal/libgdal.py 2020-07-09 22:35:08.679095615 +0100
@@ -14,7 +14,7 @@
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 -Nur a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
--- a/django/contrib/gis/geos/libgeos.py 2020-07-09 22:34:05.331568941 +0100
+++ b/django/contrib/gis/geos/libgeos.py 2020-07-09 22:36:24.863526276 +0100
@@ -24,7 +24,7 @@
from django.conf import settings
lib_path = settings.GEOS_LIBRARY_PATH
except (AttributeError, ImportError, ImproperlyConfigured, OSError):
- lib_path = None
+ lib_path = "@geos_3_9@/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 28302440c7..278cfa5e62 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -200,7 +200,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,26 @@
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:

View File

@ -0,0 +1,13 @@
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)

View File

@ -0,0 +1,51 @@
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"):

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