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