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 ] ++ twisted.optional-dependencies.tls;
53
54 nativeCheckInputs = [
55 django
56 hypothesis
57 pytest-asyncio
58 pytestCheckHook
59 ];
60
61 # Most tests fail on darwin
62 doCheck = !stdenv.hostPlatform.isDarwin;
63
64 pythonImportsCheck = [ "daphne" ];
65
66 meta = with lib; {
67 description = "Django ASGI (HTTP/WebSocket) server";
68 homepage = "https://github.com/django/daphne";
69 changelog = "https://github.com/django/daphne/blob/${version}/CHANGELOG.txt";
70 license = licenses.bsd3;
71 maintainers = [ ];
72 mainProgram = "daphne";
73 };
74}