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
|
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
replaceVars,
# build-system
setuptools,
# patched in
geos,
gdal,
withGdal ? false,
# dependencies
asgiref,
sqlparse,
# optional-dependencies
argon2-cffi,
bcrypt,
# tests
aiosmtpd,
docutils,
geoip2,
jinja2,
numpy,
pillow,
pylibmc,
pymemcache,
python,
pyyaml,
pytz,
redis,
selenium,
tblib,
tzdata,
}:
buildPythonPackage rec {
pname = "django";
version = "5.2.9";
pyproject = true;
src = fetchFromGitHub {
owner = "django";
repo = "django";
tag = version;
hash = "sha256-9URe8hB15WP92AU1YgGGFfZhVxn59gfBRrORZ04L+F0=";
};
patches = [
(replaceVars ./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 expects timezone issues
./django_5_disable_failing_tests.patch
# 3.14.1/3.13.10 comapt
(fetchpatch {
# https://github.com/django/django/pull/20390
url = "https://github.com/django/django/commit/5ca0f62213911a77dd4a62e843db7e420cc98b78.patch";
hash = "sha256-SpVdbS4S5wqvrrUOoZJ7d2cIbtmgI0mvxwwCveSA068=";
})
(fetchpatch {
# https://github.com/django/django/pull/20392
url = "https://github.com/django/django/commit/9cc231e8243091519f5d627cd02ee40bbb853ced.patch";
hash = "sha256-/aimmqxurMCCntraxOtybEq8qNgZgQWLD5Gxs/3pkIU=";
})
]
++ lib.optionals withGdal [
(replaceVars ./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-fail "/usr/bin/python" "${python.interpreter}"
'';
build-system = [ setuptools ];
dependencies = [
asgiref
sqlparse
];
optional-dependencies = {
argon2 = [ argon2-cffi ];
bcrypt = [ bcrypt ];
};
nativeCheckInputs = [
# tests/requirements/py3.txt
aiosmtpd
docutils
geoip2
jinja2
numpy
pillow
pylibmc
pymemcache
pyyaml
pytz
redis
selenium
tblib
tzdata
]
++ lib.concatAttrValues optional-dependencies;
preCheck = ''
# make sure the installed library gets imported
rm -rf django
# fails to import github_links from docs/_ext/github_links.py
rm tests/sphinx/test_github_links.py
# provide timezone data, works only on linux
export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo
export PYTHONPATH=$PWD/docs/_ext:$PYTHONPATH
'';
checkPhase = ''
runHook preCheck
pushd tests
# without --parallel=1, tests fail with an "unexpected error due to a database lock" on Darwin
${python.interpreter} runtests.py --settings=test_sqlite ${lib.optionalString stdenv.hostPlatform.isDarwin "--parallel=1"}
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";
homepage = "https://www.djangoproject.com";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ hexa ];
};
}
|