about summary refs log tree commit diff
path: root/pkgs/development/python-modules/fastapi/default.nix
blob: 67193638dd5a64be40adf425409797c48335a4d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, pythonRelaxDepsHook

# build-system
, hatchling

# dependencies
, starlette
, pydantic
, typing-extensions

# tests
, dirty-equals
, flask
, passlib
, pytest-asyncio
, pytestCheckHook
, python-jose
, sqlalchemy
, trio

# optional-dependencies
, httpx
, jinja2
, python-multipart
, itsdangerous
, pyyaml
, ujson
, orjson
, email-validator
, uvicorn
, pydantic-settings
, pydantic-extra-types
}:

buildPythonPackage rec {
  pname = "fastapi";
  version = "0.110.0";
  pyproject = true;

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "tiangolo";
    repo = "fastapi";
    rev = "refs/tags/${version}";
    hash = "sha256-OXWJ1PKJSJGzYNT8HHXvxMxjUtI4K6edpI+Z5B3TvhI=";
  };

  nativeBuildInputs = [
    hatchling
    pythonRelaxDepsHook
  ];

  pythonRelaxDeps = [
    "anyio"
    # https://github.com/tiangolo/fastapi/pull/9636
    "starlette"
  ];

  propagatedBuildInputs = [
    starlette
    pydantic
    typing-extensions
  ];

  passthru.optional-dependencies.all = [
    httpx
    jinja2
    python-multipart
    itsdangerous
    pyyaml
    ujson
    orjson
    email-validator
    uvicorn
  ] ++ lib.optionals (lib.versionAtLeast pydantic.version "2") [
    pydantic-settings
    pydantic-extra-types
  ] ++ uvicorn.optional-dependencies.standard;

  nativeCheckInputs = [
    dirty-equals
    flask
    passlib
    pytestCheckHook
    pytest-asyncio
    python-jose
    trio
    sqlalchemy
  ] ++ passthru.optional-dependencies.all
  ++ python-jose.optional-dependencies.cryptography;

  pytestFlagsArray = [
    # ignoring deprecation warnings to avoid test failure from
    # tests/test_tutorial/test_testing/test_tutorial001.py
    "-W ignore::DeprecationWarning"
  ];

  disabledTestPaths = [
    # Don't test docs and examples
    "docs_src"
    # databases is incompatible with SQLAlchemy 2.0
    "tests/test_tutorial/test_async_sql_databases"
    "tests/test_tutorial/test_sql_databases"
  ];

  pythonImportsCheck = [
    "fastapi"
  ];

  meta = with lib; {
    changelog = "https://github.com/tiangolo/fastapi/releases/tag/${version}";
    description = "Web framework for building APIs";
    homepage = "https://github.com/tiangolo/fastapi";
    license = licenses.mit;
    maintainers = with maintainers; [ wd15 ];
  };
}