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.34.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-bOHHDwkTa742yRUhXh8NjbC95VabtRnQjBPk+q/tkxY=";
31 };
32
33 outputs = [
34 "out"
35 "testsout"
36 ];
37
38 build-system = [ hatchling ];
39
40 dependencies = [
41 click
42 h11
43 ] ++ lib.optionals (pythonOlder "3.11") [ typing-extensions ];
44
45 optional-dependencies.standard = [
46 httptools
47 python-dotenv
48 pyyaml
49 uvloop
50 watchfiles
51 websockets
52 ];
53
54 postInstall = ''
55 mkdir $testsout
56 cp -R tests $testsout/tests
57 '';
58
59 pythonImportsCheck = [ "uvicorn" ];
60
61 # check in passthru.tests.pytest to escape infinite recursion with httpx/httpcore
62 doCheck = false;
63
64 passthru.tests = {
65 pytest = callPackage ./tests.nix { };
66 };
67
68 meta = with lib; {
69 homepage = "https://www.uvicorn.org/";
70 changelog = "https://github.com/encode/uvicorn/blob/${src.tag}/CHANGELOG.md";
71 description = "Lightning-fast ASGI server";
72 mainProgram = "uvicorn";
73 license = licenses.bsd3;
74 maintainers = with maintainers; [ wd15 ];
75 };
76}