1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
{
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.27";
pyproject = true;
disabled = pythonAtLeast "3.13";
src = fetchFromGitHub {
owner = "django";
repo = "django";
tag = version;
hash = "sha256-vdY85Ib2knRFLPmZZ6ojiD5R9diuvpVut1+nOVXSp0Y=";
};
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 ];
};
}
|