xtr-cli 6.5.0__tar.gz → 6.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/PKG-INFO +8 -2
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/README.md +7 -1
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/pyproject.toml +1 -1
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/pyproject.toml.orig +1 -1
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/web/__main__.py.tmpl +6 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/template.toml +3 -1
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/web_entry_point.py +13 -2
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/LICENSE +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/__init__.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/__main__.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/command/__init__.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/command/init_command.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/command/new_command.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/command/serve_command.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/command_support.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/__init__.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/ambiguous_web_entry_point_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/cli_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/directory_not_empty_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/invalid_project_name_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/invalid_template_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/project_not_found_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/step_failed_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/unknown_template_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/unsupported_python_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/exception/web_entry_point_not_found_error.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/process_runner_interface.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/project_name.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/project_settings.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/py.typed +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/scaffold_plan.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/scaffolder.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/subprocess_runner.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/template.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/template_catalog.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/__init__.py +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/AGENTS.md.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/README.md.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/__main__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/command/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/command/hello_command.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/config/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/config/packages/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/config/packages/dotenv.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/kernel.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/py.typed.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/bin/console.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/gitignore.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/pyproject.toml.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/python-version.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/tests/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/tests/test_kernel.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/template.toml +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/AGENTS.md.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/README.md.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/__main__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/command/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/command/hello_command.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/config/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/config/packages/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/config/packages/dotenv.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/config/packages/http_kernel.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/kernel.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/py.typed.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/web/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/web/app.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/web/routes.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/bin/console.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/gitignore.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/pyproject.toml.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/python-version.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/tests/__init__.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/tests/test_kernel.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/tests/test_web.py.tmpl +0 -0
- {xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/web_entry_point_finder.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xtr-cli
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.7.0
|
|
4
4
|
Summary: Scaffolds a new xtr application — a console application or a web application — in one command, and serves it.
|
|
5
5
|
Keywords: scaffold,new project,template,console,web,xtr-dependency-injection
|
|
6
6
|
Author: Xterr
|
|
@@ -162,7 +162,13 @@ The web entry point is found by reading the project's files, never by importing
|
|
|
162
162
|
2. **An ASGI application** — only when there is no such script: a module-level
|
|
163
163
|
`FastAPI()`, `Starlette()` or `Litestar()`, handed to `uv run uvicorn module:attribute`, on
|
|
164
164
|
`127.0.0.1:8000` unless told otherwise. `uvicorn` must be installed in the project, and
|
|
165
|
-
nothing the application does at startup outside that module runs.
|
|
165
|
+
nothing the application does at startup outside that module runs. It is served with
|
|
166
|
+
`UVICORN_RESET_CONTEXTVARS=1`, so each request starts in a context of its own rather than
|
|
167
|
+
with the context variables of an earlier one on the same connection; a `uvicorn` older than
|
|
168
|
+
0.45 does not know the setting and ignores it.
|
|
169
|
+
|
|
170
|
+
The `webapp` template's `<name>-web` asks its server for the same thing itself
|
|
171
|
+
(`reset_contextvars=True`), which is why the template installs `uvicorn>=0.45`.
|
|
166
172
|
|
|
167
173
|
Several candidates are offered to choose from; with `-n` the command fails and lists them for
|
|
168
174
|
`--entrypoint`. Ctrl-C stops the server and waits for it to finish shutting down, so the
|
|
@@ -141,7 +141,13 @@ The web entry point is found by reading the project's files, never by importing
|
|
|
141
141
|
2. **An ASGI application** — only when there is no such script: a module-level
|
|
142
142
|
`FastAPI()`, `Starlette()` or `Litestar()`, handed to `uv run uvicorn module:attribute`, on
|
|
143
143
|
`127.0.0.1:8000` unless told otherwise. `uvicorn` must be installed in the project, and
|
|
144
|
-
nothing the application does at startup outside that module runs.
|
|
144
|
+
nothing the application does at startup outside that module runs. It is served with
|
|
145
|
+
`UVICORN_RESET_CONTEXTVARS=1`, so each request starts in a context of its own rather than
|
|
146
|
+
with the context variables of an earlier one on the same connection; a `uvicorn` older than
|
|
147
|
+
0.45 does not know the setting and ignores it.
|
|
148
|
+
|
|
149
|
+
The `webapp` template's `<name>-web` asks its server for the same thing itself
|
|
150
|
+
(`reset_contextvars=True`), which is why the template installs `uvicorn>=0.45`.
|
|
145
151
|
|
|
146
152
|
Several candidates are offered to choose from; with `-n` the command fails and lists them for
|
|
147
153
|
`--entrypoint`. Ctrl-C stops the server and waits for it to finish shutting down, so the
|
|
@@ -35,6 +35,12 @@ def main() -> None:
|
|
|
35
35
|
# The application's own sources, not the whole project: the virtual environment
|
|
36
36
|
# under it would only slow every scan down.
|
|
37
37
|
reload_dirs=[str(PROJECT_DIR / "src")],
|
|
38
|
+
# Each request starts in a context of its own. Left off, a request on a kept-alive
|
|
39
|
+
# connection can start with the context variables an earlier one set — yours, and
|
|
40
|
+
# those of every library you use. The price: a context variable set before the
|
|
41
|
+
# server starts no longer reaches a request, so hand such a value over through the
|
|
42
|
+
# application's state instead.
|
|
43
|
+
reset_contextvars=True,
|
|
38
44
|
)
|
|
39
45
|
|
|
40
46
|
|
|
@@ -19,7 +19,9 @@ packages = [
|
|
|
19
19
|
"xtr-notifier",
|
|
20
20
|
"xtr-security",
|
|
21
21
|
"fastapi",
|
|
22
|
-
|
|
22
|
+
# The first release that can start each request in a context of its own, which
|
|
23
|
+
# the web entry point asks for.
|
|
24
|
+
"uvicorn>=0.45",
|
|
23
25
|
]
|
|
24
26
|
dev = ["xtr-recipes", "pytest", "httpx", "ruff", "basedpyright", "ty"]
|
|
25
27
|
|
|
@@ -13,6 +13,15 @@ DEFAULT_HOST: Final = "127.0.0.1"
|
|
|
13
13
|
DEFAULT_PORT: Final = 8000
|
|
14
14
|
"""The port an application found as an ASGI object is served on when none is given."""
|
|
15
15
|
|
|
16
|
+
_RESET_CONTEXTVARS: Final = "UVICORN_RESET_CONTEXTVARS"
|
|
17
|
+
"""The server's variable for starting each request in a context of its own.
|
|
18
|
+
|
|
19
|
+
On a kept-alive connection the server may otherwise start a request with the
|
|
20
|
+
context variables of an earlier one. Set as a variable rather than passed as
|
|
21
|
+
the flag it stands for: a server too old to know the setting ignores the
|
|
22
|
+
variable, where it would refuse the flag and serve nothing.
|
|
23
|
+
"""
|
|
24
|
+
|
|
16
25
|
|
|
17
26
|
@final
|
|
18
27
|
@dataclass(frozen=True, slots=True)
|
|
@@ -29,7 +38,9 @@ class WebEntryPoint:
|
|
|
29
38
|
An **ASGI object** — a module-level ``FastAPI()``, ``Starlette()`` or
|
|
30
39
|
``Litestar()`` — is handed to ``uvicorn`` directly, which then has to be
|
|
31
40
|
installed in the project. Nothing runs before it is imported, so the
|
|
32
|
-
application's own environment loading does not either.
|
|
41
|
+
application's own environment loading does not either. It is served with
|
|
42
|
+
each request started in a context of its own, where the installed server
|
|
43
|
+
knows how; a script decides that for itself.
|
|
33
44
|
|
|
34
45
|
Attributes:
|
|
35
46
|
kind: ``"script"`` or ``"asgi"``.
|
|
@@ -73,4 +84,4 @@ class WebEntryPoint:
|
|
|
73
84
|
"--port",
|
|
74
85
|
str(port if port is not None else DEFAULT_PORT),
|
|
75
86
|
)
|
|
76
|
-
return ((*argv, "--reload") if reload else argv), {}
|
|
87
|
+
return ((*argv, "--reload") if reload else argv), {_RESET_CONTEXTVARS: "1"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/command/__init__.py.tmpl
RENAMED
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/command/hello_command.py.tmpl
RENAMED
|
File without changes
|
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/config/packages/__init__.py.tmpl
RENAMED
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/cli/files/app/config/packages/dotenv.py.tmpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/command/__init__.py.tmpl
RENAMED
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/command/hello_command.py.tmpl
RENAMED
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/app/config/__init__.py.tmpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xtr_cli-6.5.0 → xtr_cli-6.7.0}/src/xtr_cli/templates/webapp/files/tests/test_kernel.py.tmpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|