1{
2 lib,
3 buildPythonPackage,
4 callPackage,
5 fetchFromGitHub,
6 click,
7 h11,
8 httptools,
9 python-dotenv,
10 pyyaml,
11 typing-extensions,
12 uvloop,
13 watchfiles,
14 websockets,
15 hatchling,
16 pythonOlder,
17}:
18
19buildPythonPackage rec {
20 pname = "uvicorn";
21 version = "0.35.0";
22 disabled = pythonOlder "3.8";
23
24 pyproject = true;
25
26 src = fetchFromGitHub {
27 owner = "encode";
28 repo = "uvicorn";
29 tag = version;
30 hash = "sha256-6tuLL0KMggujYI97HSSBHjiLrePwEkxFHjq2HWl8kqE=";
31 };
32
33 outputs = [
34 "out"
35 "testsout"
36 ];
37
38 build-system = [ hatchling ];
39
40 dependencies = [
41 click
42 h11
43 ]
44 ++ lib.optionals (pythonOlder "3.11") [ typing-extensions ];
45
46 optional-dependencies.standard = [
47 httptools
48 python-dotenv
49 pyyaml
50 uvloop
51 watchfiles
52 websockets
53 ];
54
55 postInstall = ''
56 mkdir $testsout
57 cp -R tests $testsout/tests
58 '';
59
60 pythonImportsCheck = [ "uvicorn" ];
61
62 # check in passthru.tests.pytest to escape infinite recursion with httpx/httpcore
63 doCheck = false;
64
65 passthru.tests = {
66 pytest = callPackage ./tests.nix { };
67 };
68
69 meta = with lib; {
70 homepage = "https://www.uvicorn.org/";
71 changelog = "https://github.com/encode/uvicorn/blob/${src.tag}/CHANGELOG.md";
72 description = "Lightning-fast ASGI server";
73 mainProgram = "uvicorn";
74 license = licenses.bsd3;
75 maintainers = with maintainers; [ wd15 ];
76 };
77}