1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, pythonOlder
6, substituteAll
7
8# build
9, setuptools
10
11# patched in
12, geos
13, gdal
14, withGdal ? false
15
16# propagates
17, asgiref
18, sqlparse
19
20# extras
21, argon2-cffi
22, bcrypt
23
24# tests
25, aiosmtpd
26, docutils
27, geoip2
28, jinja2
29, numpy
30, pillow
31, pylibmc
32, pymemcache
33, python
34, pywatchman
35, pyyaml
36, pytz
37, redis
38, selenium
39, tblib
40, tzdata
41}:
42
43buildPythonPackage rec {
44 pname = "Django";
45 version = "4.2.7";
46 format = "pyproject";
47
48 disabled = pythonOlder "3.10";
49
50 src = fetchPypi {
51 inherit pname version;
52 hash = "sha256-jg8cLCeGtcDjn+GvziTJJgQPrUfI6orTCq8RiN8p/EE=";
53 };
54
55 patches = [
56 (substituteAll {
57 src = ./django_4_set_zoneinfo_dir.patch;
58 zoneinfo = tzdata + "/share/zoneinfo";
59 })
60 # make sure the tests don't remove packages from our pythonpath
61 # and disable failing tests
62 ./django_4_tests.patch
63 ] ++ lib.optionals withGdal [
64 (substituteAll {
65 src = ./django_4_set_geos_gdal_lib.patch;
66 geos = geos;
67 gdal = gdal;
68 extension = stdenv.hostPlatform.extensions.sharedLibrary;
69 })
70 ];
71
72 postPatch = ''
73 substituteInPlace tests/utils_tests/test_autoreload.py \
74 --replace "/usr/bin/python" "${python.interpreter}"
75 '';
76
77 nativeBuildInputs = [
78 setuptools
79 ];
80
81 propagatedBuildInputs = [
82 asgiref
83 sqlparse
84 ];
85
86 passthru.optional-dependencies = {
87 argon2 = [
88 argon2-cffi
89 ];
90 bcrypt = [
91 bcrypt
92 ];
93 };
94
95 nativeCheckInputs = [
96 # tests/requirements/py3.txt
97 aiosmtpd
98 docutils
99 geoip2
100 jinja2
101 numpy
102 pillow
103 pylibmc
104 pymemcache
105 pywatchman
106 pyyaml
107 pytz
108 redis
109 selenium
110 tblib
111 tzdata
112 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
113
114 doCheck = !stdenv.isDarwin;
115
116 preCheck = ''
117 # make sure the installed library gets imported
118 rm -rf django
119
120 # provide timezone data, works only on linux
121 export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo
122 '';
123
124 checkPhase = ''
125 runHook preCheck
126
127 pushd tests
128 ${python.interpreter} runtests.py --settings=test_sqlite
129 popd
130
131 runHook postCheck
132 '';
133
134 __darwinAllowLocalNetworking = true;
135
136 meta = with lib; {
137 changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor version}/releases/${version}/";
138 description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design.";
139 homepage = "https://www.djangoproject.com";
140 license = licenses.bsd3;
141 maintainers = with maintainers; [ hexa ];
142 };
143}