Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 150 lines 3.0 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 fetchpatch, 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 pywatchman, 37 pyyaml, 38 pytz, 39 redis, 40 selenium, 41 tblib, 42 tzdata, 43}: 44 45buildPythonPackage rec { 46 pname = "django"; 47 version = "5.2.1"; 48 pyproject = true; 49 50 disabled = pythonOlder "3.10"; 51 52 src = fetchFromGitHub { 53 owner = "django"; 54 repo = "django"; 55 rev = "refs/tags/${version}"; 56 hash = "sha256-JmO2IEWrpA7/FXOwESLvIIuHmi2HQgvg28LVNmBXgLA="; 57 }; 58 59 patches = 60 [ 61 (replaceVars ./django_5_set_zoneinfo_dir.patch { 62 zoneinfo = tzdata + "/share/zoneinfo"; 63 }) 64 # prevent tests from messing with our pythonpath 65 ./django_5_tests_pythonpath.patch 66 # disable test that expects timezone issues 67 ./django_5_disable_failing_tests.patch 68 ] 69 ++ lib.optionals withGdal [ 70 (replaceVars ./django_5_set_geos_gdal_lib.patch { 71 geos = geos; 72 gdal = gdal; 73 extension = stdenv.hostPlatform.extensions.sharedLibrary; 74 }) 75 ]; 76 77 postPatch = '' 78 substituteInPlace tests/utils_tests/test_autoreload.py \ 79 --replace-fail "/usr/bin/python" "${python.interpreter}" 80 ''; 81 82 build-system = [ setuptools ]; 83 84 dependencies = [ 85 asgiref 86 sqlparse 87 ]; 88 89 optional-dependencies = { 90 argon2 = [ argon2-cffi ]; 91 bcrypt = [ bcrypt ]; 92 }; 93 94 nativeCheckInputs = [ 95 # tests/requirements/py3.txt 96 aiosmtpd 97 docutils 98 geoip2 99 jinja2 100 numpy 101 pillow 102 pylibmc 103 pymemcache 104 pywatchman 105 pyyaml 106 pytz 107 redis 108 selenium 109 tblib 110 tzdata 111 ] ++ lib.flatten (lib.attrValues optional-dependencies); 112 113 doCheck = 114 !stdenv.hostPlatform.isDarwin 115 # pywatchman depends on folly which does not support 32bits 116 && !stdenv.hostPlatform.is32bit; 117 118 preCheck = '' 119 # make sure the installed library gets imported 120 rm -rf django 121 122 # fails to import github_links from docs/_ext/github_links.py 123 rm tests/sphinx/test_github_links.py 124 125 # provide timezone data, works only on linux 126 export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo 127 128 export PYTHONPATH=$PWD/docs/_ext:$PYTHONPATH 129 ''; 130 131 checkPhase = '' 132 runHook preCheck 133 134 pushd tests 135 ${python.interpreter} runtests.py --settings=test_sqlite 136 popd 137 138 runHook postCheck 139 ''; 140 141 __darwinAllowLocalNetworking = true; 142 143 meta = with lib; { 144 changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor version}/releases/${version}/"; 145 description = "High-level Python Web framework that encourages rapid development and clean, pragmatic design"; 146 homepage = "https://www.djangoproject.com"; 147 license = licenses.bsd3; 148 maintainers = with maintainers; [ hexa ]; 149 }; 150}