nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 replaceVars,
8
9 # build-system
10 setuptools,
11
12 # patched in
13 geos,
14 gdal,
15 withGdal ? false,
16
17 # dependencies
18 asgiref,
19 sqlparse,
20
21 # optional-dependencies
22 argon2-cffi,
23 bcrypt,
24
25 # tests
26 aiosmtpd,
27 docutils,
28 geoip2,
29 jinja2,
30 numpy,
31 pillow,
32 pylibmc,
33 pymemcache,
34 python,
35 pyyaml,
36 pytz,
37 redis,
38 selenium,
39 tblib,
40 tzdata,
41}:
42
43buildPythonPackage rec {
44 pname = "django";
45 version = "5.2.9";
46 pyproject = true;
47
48 src = fetchFromGitHub {
49 owner = "django";
50 repo = "django";
51 tag = version;
52 hash = "sha256-9URe8hB15WP92AU1YgGGFfZhVxn59gfBRrORZ04L+F0=";
53 };
54
55 patches = [
56 (replaceVars ./django_5_set_zoneinfo_dir.patch {
57 zoneinfo = tzdata + "/share/zoneinfo";
58 })
59 # prevent tests from messing with our pythonpath
60 ./django_5_tests_pythonpath.patch
61 # disable test that expects timezone issues
62 ./django_5_disable_failing_tests.patch
63
64 # 3.14.1/3.13.10 comapt
65 (fetchpatch {
66 # https://github.com/django/django/pull/20390
67 url = "https://github.com/django/django/commit/5ca0f62213911a77dd4a62e843db7e420cc98b78.patch";
68 hash = "sha256-SpVdbS4S5wqvrrUOoZJ7d2cIbtmgI0mvxwwCveSA068=";
69 })
70 (fetchpatch {
71 # https://github.com/django/django/pull/20392
72 url = "https://github.com/django/django/commit/9cc231e8243091519f5d627cd02ee40bbb853ced.patch";
73 hash = "sha256-/aimmqxurMCCntraxOtybEq8qNgZgQWLD5Gxs/3pkIU=";
74 })
75 ]
76 ++ lib.optionals withGdal [
77 (replaceVars ./django_5_set_geos_gdal_lib.patch {
78 geos = geos;
79 gdal = gdal;
80 extension = stdenv.hostPlatform.extensions.sharedLibrary;
81 })
82 ];
83
84 postPatch = ''
85 substituteInPlace tests/utils_tests/test_autoreload.py \
86 --replace-fail "/usr/bin/python" "${python.interpreter}"
87 '';
88
89 build-system = [ setuptools ];
90
91 dependencies = [
92 asgiref
93 sqlparse
94 ];
95
96 optional-dependencies = {
97 argon2 = [ argon2-cffi ];
98 bcrypt = [ bcrypt ];
99 };
100
101 nativeCheckInputs = [
102 # tests/requirements/py3.txt
103 aiosmtpd
104 docutils
105 geoip2
106 jinja2
107 numpy
108 pillow
109 pylibmc
110 pymemcache
111 pyyaml
112 pytz
113 redis
114 selenium
115 tblib
116 tzdata
117 ]
118 ++ lib.concatAttrValues optional-dependencies;
119
120 preCheck = ''
121 # make sure the installed library gets imported
122 rm -rf django
123
124 # fails to import github_links from docs/_ext/github_links.py
125 rm tests/sphinx/test_github_links.py
126
127 # provide timezone data, works only on linux
128 export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo
129
130 export PYTHONPATH=$PWD/docs/_ext:$PYTHONPATH
131 '';
132
133 checkPhase = ''
134 runHook preCheck
135
136 pushd tests
137 # without --parallel=1, tests fail with an "unexpected error due to a database lock" on Darwin
138 ${python.interpreter} runtests.py --settings=test_sqlite ${lib.optionalString stdenv.hostPlatform.isDarwin "--parallel=1"}
139 popd
140
141 runHook postCheck
142 '';
143
144 __darwinAllowLocalNetworking = true;
145
146 meta = {
147 changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor version}/releases/${version}/";
148 description = "High-level Python Web framework that encourages rapid development and clean, pragmatic design";
149 homepage = "https://www.djangoproject.com";
150 license = lib.licenses.bsd3;
151 maintainers = with lib.maintainers; [ hexa ];
152 };
153}