1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 pythonRelaxDepsHook,
7
8 # build-system
9 hatchling,
10
11 # dependencies
12 starlette,
13 pydantic,
14 typing-extensions,
15
16 # tests
17 dirty-equals,
18 flask,
19 passlib,
20 pytest-asyncio,
21 pytestCheckHook,
22 python-jose,
23 sqlalchemy,
24 trio,
25
26 # optional-dependencies
27 httpx,
28 jinja2,
29 python-multipart,
30 itsdangerous,
31 pyyaml,
32 ujson,
33 orjson,
34 email-validator,
35 uvicorn,
36 pydantic-settings,
37 pydantic-extra-types,
38}:
39
40buildPythonPackage rec {
41 pname = "fastapi";
42 version = "0.110.2";
43 pyproject = true;
44
45 disabled = pythonOlder "3.7";
46
47 src = fetchFromGitHub {
48 owner = "tiangolo";
49 repo = "fastapi";
50 rev = "refs/tags/${version}";
51 hash = "sha256-qUh5exkXVRcKIO0t4KIOZhhpsftj3BrWaL2asf8RqUI=";
52 };
53
54 nativeBuildInputs = [
55 hatchling
56 pythonRelaxDepsHook
57 ];
58
59 pythonRelaxDeps = [
60 "anyio"
61 # https://github.com/tiangolo/fastapi/pull/9636
62 "starlette"
63 ];
64
65 propagatedBuildInputs = [
66 starlette
67 pydantic
68 typing-extensions
69 ];
70
71 passthru.optional-dependencies.all =
72 [
73 httpx
74 jinja2
75 python-multipart
76 itsdangerous
77 pyyaml
78 ujson
79 orjson
80 email-validator
81 uvicorn
82 ]
83 ++ lib.optionals (lib.versionAtLeast pydantic.version "2") [
84 pydantic-settings
85 pydantic-extra-types
86 ]
87 ++ uvicorn.optional-dependencies.standard;
88
89 nativeCheckInputs = [
90 dirty-equals
91 flask
92 passlib
93 pytestCheckHook
94 pytest-asyncio
95 python-jose
96 trio
97 sqlalchemy
98 ] ++ passthru.optional-dependencies.all ++ python-jose.optional-dependencies.cryptography;
99
100 pytestFlagsArray = [
101 # ignoring deprecation warnings to avoid test failure from
102 # tests/test_tutorial/test_testing/test_tutorial001.py
103 "-W ignore::DeprecationWarning"
104 ];
105
106 disabledTestPaths = [
107 # Don't test docs and examples
108 "docs_src"
109 # databases is incompatible with SQLAlchemy 2.0
110 "tests/test_tutorial/test_async_sql_databases"
111 "tests/test_tutorial/test_sql_databases"
112 ];
113
114 pythonImportsCheck = [ "fastapi" ];
115
116 meta = with lib; {
117 changelog = "https://github.com/tiangolo/fastapi/releases/tag/${version}";
118 description = "Web framework for building APIs";
119 homepage = "https://github.com/tiangolo/fastapi";
120 license = licenses.mit;
121 maintainers = with maintainers; [ wd15 ];
122 };
123}