1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 hatchling,
8
9 # dependencies
10 anyio,
11 typing-extensions,
12
13 # optional dependencies
14 itsdangerous,
15 jinja2,
16 python-multipart,
17 pyyaml,
18 httpx,
19
20 # tests
21 pytestCheckHook,
22 pythonOlder,
23 trio,
24
25 # reverse dependencies
26 fastapi,
27}:
28
29buildPythonPackage rec {
30 pname = "starlette";
31 version = "0.47.2";
32 pyproject = true;
33
34 disabled = pythonOlder "3.8";
35
36 src = fetchFromGitHub {
37 owner = "encode";
38 repo = "starlette";
39 tag = version;
40 hash = "sha256-FseSZrLWuNaLro2iLMcfiCrbx2Gz8+aEmLaSk/+PgN4=";
41 };
42
43 build-system = [ hatchling ];
44
45 dependencies = [ anyio ] ++ lib.optionals (pythonOlder "3.10") [ typing-extensions ];
46
47 optional-dependencies.full = [
48 itsdangerous
49 jinja2
50 python-multipart
51 pyyaml
52 httpx
53 ];
54
55 nativeCheckInputs = [
56 pytestCheckHook
57 trio
58 typing-extensions
59 ]
60 ++ lib.flatten (lib.attrValues optional-dependencies);
61
62 pytestFlags = [
63 "-Wignore::DeprecationWarning"
64 "-Wignore::trio.TrioDeprecationWarning"
65 "-Wignore::ResourceWarning" # FIXME remove once test suite is fully compatible with anyio 4.4.0
66 ];
67
68 pythonImportsCheck = [ "starlette" ];
69
70 passthru.tests = {
71 inherit fastapi;
72 };
73
74 meta = with lib; {
75 changelog = "https://www.starlette.io/release-notes/#${lib.replaceStrings [ "." ] [ "" ] version}";
76 downloadPage = "https://github.com/encode/starlette";
77 homepage = "https://www.starlette.io/";
78 description = "Little ASGI framework that shines";
79 license = licenses.bsd3;
80 maintainers = with maintainers; [ wd15 ];
81 };
82}