1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 hatchling,
8
9 # dependencies
10 annotated-types,
11 anyio,
12 asyncpg,
13 attrs,
14 brotli,
15 click,
16 cryptography,
17 fsspec,
18 httpx,
19 jinja2,
20 jsbeautifier,
21 litestar-htmx,
22 mako,
23 minijinja,
24 fast-query-parsers,
25 msgspec,
26 multidict,
27 multipart,
28 picologging,
29 polyfactory,
30 piccolo,
31 prometheus-client,
32 psutil,
33 opentelemetry-instrumentation-asgi,
34 psycopg,
35 pydantic-extra-types,
36 pydantic,
37 email-validator,
38 pyjwt,
39 pyyaml,
40 redis,
41 rich-click,
42 rich,
43 structlog,
44 time-machine,
45 typing-extensions,
46 uvicorn,
47 # valkey,
48
49 # tests
50 httpx-sse,
51 pytest-asyncio,
52 pytest-lazy-fixtures,
53 pytest-mock,
54 pytest-rerunfailures,
55 pytest-timeout,
56 pytest-xdist,
57 pytestCheckHook,
58 trio,
59 versionCheckHook,
60}:
61
62buildPythonPackage rec {
63 pname = "litestar";
64 version = "2.17.0";
65 pyproject = true;
66
67 src = fetchFromGitHub {
68 owner = "litestar-org";
69 repo = "litestar";
70 tag = "v${version}";
71 hash = "sha256-jUd0Nf3OmcKmO7DAXMqBXZPw3+heAQszcgE2xT+lAyA=";
72 };
73
74 build-system = [ hatchling ];
75
76 dependencies = [
77 anyio
78 asyncpg
79 click
80 fast-query-parsers
81 fsspec
82 httpx
83 litestar-htmx
84 msgspec
85 multidict
86 multipart
87 polyfactory
88 psutil
89 pyyaml
90 rich
91 rich-click
92 typing-extensions
93 ];
94
95 optional-dependencies = {
96 annotated-types = [ annotated-types ];
97 attrs = [ attrs ];
98 brotli = [ brotli ];
99 cli = [
100 jsbeautifier
101 uvicorn
102 ];
103 cryptography = [ cryptography ];
104 htmx = [ litestar-htmx ];
105 jinja = [ jinja2 ];
106 jwt = [
107 cryptography
108 pyjwt
109 ];
110 mako = [ mako ];
111 minijinja = [ minijinja ];
112 opentelemetry = [ opentelemetry-instrumentation-asgi ];
113 piccolo = [ piccolo ];
114 picologging = [ picologging ];
115 polyfactory = [ polyfactory ];
116 prometheus = [ prometheus-client ];
117 pydantic = [
118 pydantic
119 email-validator
120 pydantic-extra-types
121 ];
122 redis = [ redis ] ++ redis.optional-dependencies.hiredis;
123 # sqlalchemy = [ advanced-alchemy ];
124 structlog = [ structlog ];
125 # valkey = [ valkey ] ++ valkey.optional-dependencies.libvalkey;
126 yaml = [ pyyaml ];
127 };
128
129 nativeCheckInputs = [
130 httpx-sse
131 pytest-asyncio
132 pytest-lazy-fixtures
133 pytest-mock
134 pytest-rerunfailures
135 pytest-timeout
136 pytest-xdist
137 pytestCheckHook
138 time-machine
139 trio
140 versionCheckHook
141 ];
142
143 versionCheckProgramArg = "version";
144
145 __darwinAllowLocalNetworking = true;
146
147 preCheck = ''
148 export PATH=$out/bin:$PATH
149 '';
150
151 enabledTestPaths = [
152 # Follow GitHub CI
153 "docs/examples/"
154 ];
155
156 disabledTests = [
157 # StartupError
158 "test_subprocess_async_client"
159 ];
160
161 meta = {
162 description = "Production-ready, Light, Flexible and Extensible ASGI API framework";
163 homepage = "https://litestar.dev/";
164 changelog = "https://github.com/litestar-org/litestar/releases/tag/${src.tag}";
165 license = lib.licenses.mit;
166 mainProgram = "litestar";
167 maintainers = with lib.maintainers; [ bot-wxt1221 ];
168 platforms = lib.platforms.unix;
169 };
170}