1{
2 lib,
3 stdenv,
4 asgiref,
5 autobahn,
6 buildPythonPackage,
7 django,
8 fetchFromGitHub,
9 fetchpatch2,
10 hypothesis,
11 pytest-asyncio,
12 pytestCheckHook,
13 pythonOlder,
14 setuptools,
15 twisted,
16}:
17
18buildPythonPackage rec {
19 pname = "daphne";
20 version = "4.1.2";
21 pyproject = true;
22
23 disabled = pythonOlder "3.8";
24
25 src = fetchFromGitHub {
26 owner = "django";
27 repo = "daphne";
28 tag = version;
29 hash = "sha256-RAK2CaKKVmVIv1MBK+9xyADOrHq664MQOry4KaGTNCw=";
30 };
31
32 patches = [
33 # https://github.com/django/daphne/pull/526
34 (fetchpatch2 {
35 name = "fix-tests-with-Twisted-24.7.0.patch";
36 url = "https://github.com/django/daphne/commit/0370c7a0937011d5345b14d484ec171d3ae9f875.patch";
37 hash = "sha256-/3d2pRcEtGvINGHRQF3RZ8IVIETSZb6rhf+ZHUFSQQo=";
38 })
39 ];
40
41 postPatch = ''
42 substituteInPlace setup.cfg \
43 --replace-fail "pytest-runner" ""
44 '';
45
46 build-system = [ setuptools ];
47
48 dependencies = [
49 asgiref
50 autobahn
51 twisted
52 ]
53 ++ twisted.optional-dependencies.tls;
54
55 nativeCheckInputs = [
56 django
57 hypothesis
58 pytest-asyncio
59 pytestCheckHook
60 ];
61
62 # Most tests fail on darwin
63 doCheck = !stdenv.hostPlatform.isDarwin;
64
65 pythonImportsCheck = [ "daphne" ];
66
67 meta = with lib; {
68 description = "Django ASGI (HTTP/WebSocket) server";
69 homepage = "https://github.com/django/daphne";
70 changelog = "https://github.com/django/daphne/blob/${version}/CHANGELOG.txt";
71 license = licenses.bsd3;
72 maintainers = [ ];
73 mainProgram = "daphne";
74 };
75}