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