Files
nixpkgs/pkgs/development/python-modules/django/6.nix
T

144 lines
2.9 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
pythonOlder,
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 (finalAttrs: {
pname = "django";
version = "6.0.3";
pyproject = true;
disabled = pythonOlder "3.12";
src = fetchFromGitHub {
owner = "django";
repo = "django";
tag = finalAttrs.version;
hash = "sha256-FXaK9e2/grRH0c4r/t+Sm9uyYHlSUx6S0klnYTW/8KQ=";
};
patches = [
(replaceVars ./6.x/zoneinfo.patch {
zoneinfo = tzdata + "/share/zoneinfo";
})
# prevent tests from messing with our pythonpath
./6.x/pythonpath.patch
# test_incorrect_timezone should raise but doesn't
./6.x/disable-failing-test.patch
]
++ lib.optionals withGdal [
(replaceVars ./6.x/gdal.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 finalAttrs.passthru.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 = with lib; {
changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor finalAttrs.version}/releases/${finalAttrs.version}/";
description = "High-level Python Web framework that encourages rapid development and clean, pragmatic design";
homepage = "https://www.djangoproject.com";
license = licenses.bsd3;
maintainers = with maintainers; [ hexa ];
};
})