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