1{
2 lib,
3 buildPythonPackage,
4 pythonAtLeast,
5 pythonOlder,
6 isPyPy,
7 fetchFromGitHub,
8
9 # build
10 cython,
11 setuptools,
12
13 # tests
14 aiofiles,
15 cbor2,
16 httpx,
17 msgpack,
18 mujson,
19 orjson,
20 pytest-asyncio,
21 pytest7CheckHook,
22 pyyaml,
23 rapidjson,
24 requests,
25 testtools,
26 ujson,
27 uvicorn,
28 websockets,
29}:
30
31buildPythonPackage rec {
32 pname = "falcon";
33 version = "3.1.3";
34 format = "pyproject";
35 disabled = pythonOlder "3.5";
36
37 src = fetchFromGitHub {
38 owner = "falconry";
39 repo = pname;
40 rev = "refs/tags/${version}";
41 hash = "sha256-7719gOM8WQVjODwOSo7HpH3HMFFeCGQQYBKktBAevig=";
42 };
43
44 nativeBuildInputs = [ setuptools ] ++ lib.optionals (!isPyPy) [ cython ];
45
46 __darwinAllowLocalNetworking = true;
47
48 preCheck = ''
49 export HOME=$TMPDIR
50 cp -R tests examples $TMPDIR
51 pushd $TMPDIR
52 '';
53
54 postCheck = ''
55 popd
56 '';
57
58 nativeCheckInputs = [
59 # https://github.com/falconry/falcon/blob/master/requirements/tests
60 pytest7CheckHook
61 pyyaml
62 requests
63 rapidjson
64 orjson
65
66 # ASGI specific
67 pytest-asyncio
68 aiofiles
69 httpx
70 uvicorn
71 websockets
72
73 # handler specific
74 cbor2
75 msgpack
76 mujson
77 ujson
78 ] ++ lib.optionals (pythonOlder "3.10") [ testtools ];
79
80 pytestFlagsArray = [ "tests" ];
81
82 disabledTestPaths =
83 [
84 # needs a running server
85 "tests/asgi/test_asgi_servers.py"
86 ]
87 ++ lib.optionals (pythonAtLeast "3.12") [
88 # ModuleNotFoundError: No module named 'distutils'
89 "tests/asgi/test_cythonized_asgi.py"
90 ];
91
92 meta = with lib; {
93 description = "An unladen web framework for building APIs and app backends";
94 homepage = "https://falconframework.org/";
95 license = licenses.asl20;
96 maintainers = with maintainers; [ desiderius ];
97 };
98}