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, hatchling
15, pythonOlder
16}:
17
18buildPythonPackage rec {
19 pname = "uvicorn";
20 version = "0.23.2";
21 disabled = pythonOlder "3.8";
22
23 format = "pyproject";
24
25 src = fetchFromGitHub {
26 owner = "encode";
27 repo = pname;
28 rev = "refs/tags/${version}";
29 hash = "sha256-98Ahb6syD/J9StwaOqVj/MCdzbHOgey0sixp7SJnROE=";
30 };
31
32 outputs = [
33 "out"
34 "testsout"
35 ];
36
37 nativeBuildInputs = [ hatchling ];
38
39 propagatedBuildInputs = [
40 click
41 h11
42 ] ++ lib.optionals (pythonOlder "3.11") [
43 typing-extensions
44 ];
45
46 passthru.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 = [
61 "uvicorn"
62 ];
63
64 # check in passthru.tests.pytest to escape infinite recursion with httpx/httpcore
65 doCheck = false;
66
67 passthru.tests = {
68 pytest = callPackage ./tests.nix { };
69 };
70
71 meta = with lib; {
72 homepage = "https://www.uvicorn.org/";
73 changelog = "https://github.com/encode/uvicorn/blob/${src.rev}/CHANGELOG.md";
74 description = "The lightning-fast ASGI server";
75 license = licenses.bsd3;
76 maintainers = with maintainers; [ wd15 ];
77 };
78}