django-compose 0.1.0.dev8__tar.gz → 0.1.0.dev9__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.
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/CHANGELOG.md +6 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/PKG-INFO +1 -1
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/README.md +1 -1
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/SPEC.md +12 -32
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/api.md +5 -6
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/configuration.md +18 -14
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/proposals/0001-native-url-collisions.md +6 -3
- django_compose-0.1.0.dev9/docs/proposals/0004-serving-boundary.md +38 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/quickstart.md +1 -1
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/README.md +9 -13
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/apps.py +1 -9
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/settings.py +0 -2
- django_compose-0.1.0.dev9/examples/shop/urls.py +5 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/verify.py +2 -22
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/pyproject.toml +1 -1
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/scripts/check_distribution.py +0 -3
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/apps.py +0 -1
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/__init__.py +12 -53
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/snapshot.py +6 -3
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_boundaries.py +5 -16
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_conf.py +8 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_launcher.py +31 -43
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_snapshot.py +7 -10
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/uv.lock +1 -1
- django_compose-0.1.0.dev8/examples/shop/catalog/management/commands/verify_context.py +0 -21
- django_compose-0.1.0.dev8/examples/shop/catalog/transport.py +0 -17
- django_compose-0.1.0.dev8/examples/shop/contexts.py +0 -19
- django_compose-0.1.0.dev8/examples/shop/reviews/__init__.py +0 -0
- django_compose-0.1.0.dev8/examples/shop/urls.py +0 -3
- django_compose-0.1.0.dev8/src/django_compose/__init__.py +0 -0
- django_compose-0.1.0.dev8/src/django_compose/asgi.py +0 -110
- django_compose-0.1.0.dev8/src/django_compose/checks.py +0 -11
- django_compose-0.1.0.dev8/src/django_compose/urls.py +0 -79
- django_compose-0.1.0.dev8/tests/test_asgi.py +0 -201
- django_compose-0.1.0.dev8/tests/test_command_context.py +0 -179
- django_compose-0.1.0.dev8/tests/test_urls.py +0 -285
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/.gitignore +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/AGENTS.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/CONTRIBUTING.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/COPYING +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/LICENSE +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/Makefile +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/NOTICE +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/README.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/ROADMAP.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/components.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/dependencies.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/extensions.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/migrations.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/models.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/packaging.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/proposals/0002-supplied-distribution-metadata.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/proposals/README.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/provisioning.md +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/.gitignore +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/__init__.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/autoconfig.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/integrations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/models.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/pyproject.toml +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/schema.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/catalog/urls.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/manage.py +0 -0
- {django_compose-0.1.0.dev8/examples/shop/catalog/management → django_compose-0.1.0.dev9/examples/shop/reviews}/__init__.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/reviews/apps.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/reviews/autoconfig.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/reviews/models.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/examples/shop/reviews/pyproject.toml +0 -0
- {django_compose-0.1.0.dev8/examples/shop/catalog/management/commands → django_compose-0.1.0.dev9/src/django_compose}/__init__.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/__main__.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/artifacts.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/autoreload.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/build.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/cli.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/components.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/conf.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/declarations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/history.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/check_migrations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/compose.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/makemigrations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/migrate.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/provision.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/reset_migration_history.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/commands/retire_history.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/migration_imports.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/migrations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/model_composition.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/models.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/provision.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/py.typed +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/rendering.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/serving.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/sources.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/typing.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/core_fixtures/__init__.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_artifacts.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_autoreload.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_bootstrap.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_components.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_history.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_initial_history.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_integrations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_migration_imports.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_migration_scaffold.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_migrations.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_migrations_guards.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_migrations_postgres.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_models.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_provision.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_provision_postgres.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_sources.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_startup.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/test_typing.py +0 -0
- {django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/tests/typing_fixtures/__init__.py +0 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0.dev9
|
|
4
|
+
|
|
5
|
+
- Remove the URL/ASGI serving and command-context seams; consumers own serving
|
|
6
|
+
(prerelease API cutoff; see [proposal 0004](docs/proposals/0004-serving-boundary.md)).
|
|
7
|
+
- Add keyword-only `utility_class` to `management.execute()`.
|
|
8
|
+
|
|
3
9
|
## 0.1.0.dev8
|
|
4
10
|
|
|
5
11
|
- Replace reusable transition discovery, binding, baseline/adoption and sealing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-compose
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev9
|
|
4
4
|
Summary: Compose reusable Django apps into a runnable project.
|
|
5
5
|
Project-URL: Source, https://github.com/ang-ee/django-compose
|
|
6
6
|
Project-URL: Documentation, https://github.com/ang-ee/django-compose/tree/main/docs
|
|
@@ -16,7 +16,7 @@ Django supplies the registry, ORM and migrations.
|
|
|
16
16
|
| --- | --- |
|
|
17
17
|
| Add fields or behavior from another app | [Model declarations](models.md) |
|
|
18
18
|
| Choose apps and follow their dependencies | [App selection and package metadata](components.md) |
|
|
19
|
-
| Contribute settings
|
|
19
|
+
| Contribute settings | [Project configuration](configuration.md#app-settings-contributions) |
|
|
20
20
|
| Generate additional files or model metadata | [Build integrations](extensions.md) |
|
|
21
21
|
| Change models, disable apps or maintain history | [Migrations](migrations.md) |
|
|
22
22
|
| Prepare a database and check readiness | [Provisioning](provisioning.md) |
|
|
@@ -17,7 +17,6 @@ defines supported versions and platforms.
|
|
|
17
17
|
- [Artifact access](#artifact-access)
|
|
18
18
|
- [Native history](#native-history)
|
|
19
19
|
- [Database preparation and readiness](#database-preparation-and-readiness)
|
|
20
|
-
- [Serving composition](#serving-composition)
|
|
21
20
|
- [Typing and import boundaries](#typing-and-import-boundaries)
|
|
22
21
|
|
|
23
22
|
## Terms
|
|
@@ -246,7 +245,6 @@ keep ordering and input ownership in one place. See the
|
|
|
246
245
|
| `COMPOSE_OUTPUT_DIR` | Project-selected generated package directory; required for building |
|
|
247
246
|
| `COMPOSE_OUTPUT_MODULE` | Import path for that directory; defaults to `"runtime"` |
|
|
248
247
|
| `COMPOSE_WATCH_PATHS` | Files and `(directory, glob)` pairs additionally watched by native reloaders |
|
|
249
|
-
| `COMPOSE_COMMAND_CONTEXT` | Ordered dotted post-setup/post-parse `(command, argv, options)` context-manager factories; empty by default |
|
|
250
248
|
| `COMPOSE_INTEGRATIONS` | Ordered dotted integration class paths; empty by default |
|
|
251
249
|
| `COMPOSE_FINGERPRINT_GLOBS` | Additional per-app source globs; empty by default |
|
|
252
250
|
| `COMPOSE_FINGERPRINT_EXCLUDES` | Source exclusion patterns; defaults to `**/tests/**`, `**/migrations/**`, `**/__pycache__/**` |
|
|
@@ -257,9 +255,9 @@ keep ordering and input ownership in one place. See the
|
|
|
257
255
|
|
|
258
256
|
Mandatory inputs include resolved app/config identities, source Python and
|
|
259
257
|
extra-glob bytes, selected config MRO implementation modules, integration modules,
|
|
260
|
-
`DEFAULT_AUTO_FIELD`, `AUTH_USER_MODEL`, authored
|
|
261
|
-
|
|
262
|
-
`
|
|
258
|
+
`DEFAULT_AUTO_FIELD`, `AUTH_USER_MODEL`, authored migration mappings, every
|
|
259
|
+
`COMPOSE_*` value except derived `COMPOSE_ROOTS`, `COMPOSE_SNAPSHOT` and
|
|
260
|
+
`COMPOSE_CLOSURE`, and compiler identity. Built-in/frozen config owners use a
|
|
263
261
|
deterministic interpreter implementation/version identity instead of file bytes.
|
|
264
262
|
A redundant root list cannot alter the digest of an unchanged resolved selection.
|
|
265
263
|
|
|
@@ -296,13 +294,11 @@ launcher is the native reloader parent: compose first, then start the serving ch
|
|
|
296
294
|
on failure watch reported candidates and retry after changes. Settings loaders
|
|
297
295
|
call `autoreload.report_inputs(files=(), globs=())` before reads. Files may be
|
|
298
296
|
absent and globs initially empty. `COMPOSE_WATCH_PATHS` extends the same owner.
|
|
299
|
-
`
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
A custom `run_from_argv` participates by calling `self.execute`; bypassing execute
|
|
305
|
-
also bypasses these contexts.
|
|
297
|
+
`execute(argv=None, *, utility_class=ManagementUtility)` dispatches through the
|
|
298
|
+
given native `ManagementUtility` class, which owns command parsing, parser errors
|
|
299
|
+
and connection cleanup. A project wraps command execution by supplying a subclass;
|
|
300
|
+
the launcher adds no middleware of its own, and the reloader parent's compose
|
|
301
|
+
subprocess uses the default dispatcher.
|
|
306
302
|
Direct Django launchers must set composition mode themselves before settings
|
|
307
303
|
load; migration commands require it to be absent.
|
|
308
304
|
|
|
@@ -511,26 +507,10 @@ under its lease and reads readiness and native migration state without repair.
|
|
|
511
507
|
The single private recorder, durable failure/retry boundary, PostgreSQL lock and
|
|
512
508
|
explicit `base_provision` table cutover are defined in [provisioning](provisioning.md).
|
|
513
509
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
and `compose_url_namespace` (default absent). The registered native system check
|
|
519
|
-
reports identical native matching chains as `django_compose.E001`, naming both
|
|
520
|
-
contributing apps. Chains must have the same include boundaries, native matcher
|
|
521
|
-
types, compiled regex text and flags, endpoint behavior, capture names and
|
|
522
|
-
converter instances. Reverse namespaces do not distinguish matches. Different
|
|
523
|
-
converters, differently expressed chains and custom matching implementations
|
|
524
|
-
retain Django's ordered resolution; the check neither executes converters nor
|
|
525
|
-
proves arbitrary regex equivalence or overlap.
|
|
526
|
-
|
|
527
|
-
`django_compose.asgi.application` composes optional `config.compose_asgi()` factories
|
|
528
|
-
returning `AsgiContribution(http_mounts=..., lifespans=..., protocols=...)`.
|
|
529
|
-
Absolute mount paths use longest-prefix matching on path boundaries; the original
|
|
530
|
-
path is retained and root_path extended. Unmounted HTTP uses Django's ASGIHandler.
|
|
531
|
-
Lifespan factories enter in app order, unwind in reverse and report startup/shutdown
|
|
532
|
-
failure. HTTP and lifespan are reserved protocols; duplicate mounts or protocol
|
|
533
|
-
claims fail. These modules require completed setup and install no server policy.
|
|
510
|
+
django-compose composes no URLconf, ASGI application or command middleware.
|
|
511
|
+
Projects route selected apps' URLconfs with Django's native `include()` and serve
|
|
512
|
+
them with Django's ASGI or WSGI handlers; see
|
|
513
|
+
[proposal 0004](proposals/0004-serving-boundary.md).
|
|
534
514
|
|
|
535
515
|
## Typing and import boundaries
|
|
536
516
|
|
|
@@ -15,7 +15,7 @@ lifecycle rules. Python module names below are relative to `django_compose`.
|
|
|
15
15
|
| API | Purpose |
|
|
16
16
|
| --- | --- |
|
|
17
17
|
| `conf.configure(namespace)` | Call once with `globals()` at the end of project settings; select apps, apply contributions and configure generated output |
|
|
18
|
-
| `management.execute(argv=None)` | Use as the [manage.py launcher](configuration.md#managepy); select composition mode before importing settings |
|
|
18
|
+
| `management.execute(argv=None, *, utility_class=ManagementUtility)` | Use as the [manage.py launcher](configuration.md#managepy); select composition mode before importing settings; dispatch through a native `ManagementUtility` subclass to wrap commands |
|
|
19
19
|
| `autoreload.report_inputs(*, files=(), globs=())` | Settings loaders report file/glob candidates **before** reading them, including absent files; see [development](configuration.md#serve-the-project) |
|
|
20
20
|
|
|
21
21
|
The launcher exposes these Django management commands:
|
|
@@ -90,14 +90,13 @@ loading project settings. It is a **standalone command**, unavailable through
|
|
|
90
90
|
| --- | --- | --- |
|
|
91
91
|
| `AppConfig.requires_apps` | App dependencies declared for composition | [Selection rules](components.md#dependency-and-configuration-rules) |
|
|
92
92
|
| `autoconfig.py`: `SETTINGS`, `settings(namespace)` | Defaults and additive settings | [App settings](configuration.md#app-settings-contributions) |
|
|
93
|
-
| `AppConfig.compose_urls`, `compose_url_prefix`, `compose_url_namespace` | URLconf contributions exposed through `django_compose.urls.urlpatterns` | [URLs](configuration.md#compose-app-urls) |
|
|
94
|
-
| `AppConfig.compose_asgi()` | Return `asgi.AsgiContribution(http_mounts=..., lifespans=..., protocols=...)` for `django_compose.asgi.application` | [ASGI contract](SPEC.md#serving-composition) |
|
|
95
93
|
| `AppConfig.compose_provision(context)` | Prepare the database after migrations using `provision.ProvisionContext` and its `call()` helper | [Provisioning](provisioning.md) |
|
|
96
94
|
| `COMPOSE_INTEGRATIONS` | Dotted classes implementing build protocols below | [Build integrations](extensions.md#supported-protocols) |
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
Settings contributions run before app population; integrations run during
|
|
97
|
+
build. Ordinary model behavior belongs in abstract model bases. URL routing and
|
|
98
|
+
ASGI serving stay with Django's native `include()` and handlers
|
|
99
|
+
([route app URLs](configuration.md#route-app-urls)). The [integration protocols](SPEC.md#integration-protocols)
|
|
101
100
|
in [`django_compose.declarations`](../src/django_compose/declarations.py) are:
|
|
102
101
|
|
|
103
102
|
- `ModelDeclarationHook.model_declaration(composition, source)` returns a literal
|
|
@@ -195,11 +195,11 @@ from django_compose.autoreload import report_inputs
|
|
|
195
195
|
report_inputs(files=(BASE_DIR / "settings.yaml", BASE_DIR / ".env"))
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
Use `COMPOSE_WATCH_PATHS` for extra files or `(directory, glob)` pairs.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
Use `COMPOSE_WATCH_PATHS` for extra files or `(directory, glob)` pairs. The
|
|
199
|
+
[lifecycle contract](SPEC.md#setup-lifecycle) defines the complete launcher
|
|
200
|
+
interface. Command dispatch is Django's native `ManagementUtility`; to wrap
|
|
201
|
+
command execution, pass a subclass as `execute(sys.argv, utility_class=...)`.
|
|
202
|
+
Explicit `COMPOSE_COMMAND_CONTEXT` configuration fails at `configure` with that guidance.
|
|
203
203
|
|
|
204
204
|
## App settings contributions
|
|
205
205
|
|
|
@@ -257,17 +257,21 @@ already included. Globs are relative to each selected app directory. Changing
|
|
|
257
257
|
`COMPOSE_FINGERPRINT_EXCLUDES` replaces its defaults; consult the
|
|
258
258
|
[input contract](SPEC.md#settings-and-snapshots) before overriding it.
|
|
259
259
|
|
|
260
|
-
##
|
|
260
|
+
## Route app URLs
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
after setup. Ordinary project-authored URLconfs remain supported.
|
|
262
|
+
django-compose does not compose URLconfs or ASGI applications. Route a selected
|
|
263
|
+
app's URLconf with Django's native `include()` in the project's `ROOT_URLCONF`,
|
|
264
|
+
and serve with Django's ordinary ASGI or WSGI application:
|
|
266
265
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
266
|
+
```python
|
|
267
|
+
# shop/urls.py
|
|
268
|
+
from django.urls import include, path
|
|
269
|
+
|
|
270
|
+
urlpatterns = [path("catalog/", include("catalog.urls"))]
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Generated models are available to views through Django's app registry as usual.
|
|
274
|
+
The [example URLconf](../examples/shop/urls.py) uses this layout.
|
|
271
275
|
|
|
272
276
|
## Startup consistency
|
|
273
277
|
|
{django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/docs/proposals/0001-native-url-collisions.md
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# 0001: preserve native URL converter semantics
|
|
2
2
|
|
|
3
|
-
Status: accepted.
|
|
3
|
+
Status: accepted; superseded by [0004](0004-serving-boundary.md), which removed
|
|
4
|
+
URL composition from django-compose. This record documents the check's semantics
|
|
5
|
+
for whichever package owns it.
|
|
4
6
|
|
|
5
7
|
Django owns URL matching through native patterns, converters and ordered
|
|
6
8
|
resolution. A converter's `to_python()` may raise `ValueError` to reject a regex
|
|
@@ -20,6 +22,7 @@ registry, setting or dependency. Identical native chains remain errors,
|
|
|
20
22
|
including duplicates reached through different reverse namespaces.
|
|
21
23
|
Valid custom-converter routes previously rejected need no caller migration.
|
|
22
24
|
|
|
23
|
-
The implemented contract
|
|
24
|
-
|
|
25
|
+
The implemented contract left this distribution with [0004](0004-serving-boundary.md);
|
|
26
|
+
the package owning the check documents it beside the check's docstring. Django's
|
|
27
|
+
[converter documentation](https://docs.djangoproject.com/en/6.1/topics/http/urls/#registering-custom-path-converters)
|
|
25
28
|
owns matching behavior.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# 0004: keep web serving and command dispatch outside the compiler
|
|
2
|
+
|
|
3
|
+
Status: accepted.
|
|
4
|
+
|
|
5
|
+
django-compose owns composition, deterministic emission, verified output,
|
|
6
|
+
native history retention and database preparation. Django owns URL resolution
|
|
7
|
+
(`include()`, `ROOT_URLCONF`), the ASGI/WSGI handlers and management command
|
|
8
|
+
dispatch (`ManagementUtility`). [AGENTS.md](../../AGENTS.md) assigns those owners
|
|
9
|
+
("Django owns application identity and population, model construction, fields,
|
|
10
|
+
managers, migration state, execution, routing, and history"); `django_compose.urls`,
|
|
11
|
+
`django_compose.asgi` and `COMPOSE_COMMAND_CONTEXT` re-owned routing and execution
|
|
12
|
+
inside the compiler. They had no dependency on the snapshot, receipt or generated
|
|
13
|
+
output.
|
|
14
|
+
|
|
15
|
+
Remove the three seams from this distribution:
|
|
16
|
+
|
|
17
|
+
- `django_compose.urls` with the `compose_urls`, `compose_url_prefix` and
|
|
18
|
+
`compose_url_namespace` AppConfig attributes and system check `django_compose.E001`
|
|
19
|
+
([0001](0001-native-url-collisions.md) records the check's semantics).
|
|
20
|
+
- `django_compose.asgi` with `AppConfig.compose_asgi()` and `AsgiContribution`.
|
|
21
|
+
- `COMPOSE_COMMAND_CONTEXT` and the launcher's command-execution wrapper. The
|
|
22
|
+
launcher dispatches through Django's `ManagementUtility`; `execute()` gains a
|
|
23
|
+
keyword-only `utility_class` so a project supplies its own subclass. That is
|
|
24
|
+
the only native extension point retained.
|
|
25
|
+
|
|
26
|
+
Caller migration: route app URLconfs with native `include()` in the project
|
|
27
|
+
URLconf; serve with Django's ASGI or WSGI application or a project-owned ASGI
|
|
28
|
+
router; wrap command execution through `utility_class` from the project's own
|
|
29
|
+
`manage.py`. A consumer framework that wants reusable URL, ASGI or command-wrapping
|
|
30
|
+
seams owns them in its own serving package, which depends on Django, not on the
|
|
31
|
+
compiler. No django-compose API replaces them.
|
|
32
|
+
|
|
33
|
+
Compatibility: this is a prerelease API cutoff recorded in the changelog. A
|
|
34
|
+
project that still sets `COMPOSE_COMMAND_CONTEXT` fails at `configure` with a
|
|
35
|
+
message pointing at `execute(..., utility_class=...)`, as the removed
|
|
36
|
+
`COMPOSE_TRANSITION_SOURCE` does. Leftover `compose_urls*` attributes and
|
|
37
|
+
`compose_asgi()` methods on an AppConfig are inert: nothing reads them, and
|
|
38
|
+
Django ignores them.
|
|
@@ -97,4 +97,4 @@ migration history when rebuilding generated files.
|
|
|
97
97
|
- [Configure your project](configuration.md) for complete settings, launcher and model files.
|
|
98
98
|
- [Model declarations](models.md) explains extensions, multi-table inheritance and constraints.
|
|
99
99
|
- [Public API](api.md) maps commands, Python entry points and app hooks.
|
|
100
|
-
- [Example details](../examples/shop/README.md) cover its settings, artifacts
|
|
100
|
+
- [Example details](../examples/shop/README.md) cover its settings, artifacts and integrations.
|
|
@@ -4,31 +4,27 @@ Compose reusable Django apps into a runnable project.
|
|
|
4
4
|
|
|
5
5
|
`catalog` declares an abstract `Item`; `reviews` adds a rating and method.
|
|
6
6
|
Both are installable example distributions in `compose.example`. The project
|
|
7
|
-
selects only `reviews`; its Requires-Dist activates catalog, whose
|
|
8
|
-
requires_apps selects Django auth/contenttypes. No
|
|
7
|
+
selects only `reviews`; its Requires-Dist activates catalog, whose
|
|
8
|
+
`requires_apps` selects Django auth/contenttypes. No other framework is needed.
|
|
9
9
|
|
|
10
10
|
Follow the [quick start](../../docs/quickstart.md) from the checkout root. Install
|
|
11
11
|
both local app distributions before composing. Then, from this directory:
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
uv run --project ../.. --no-sync python verify.py
|
|
15
|
-
uv run --project ../.. --no-sync python manage.py verify_context
|
|
16
|
-
uv run --project ../.. --no-sync python manage.py verify_context --database reporting
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
[settings.py](settings.py) composes app selection, additive defaults
|
|
20
|
-
`CATALOG_` environment overlay
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
[
|
|
24
|
-
reads a models-phase artifact, and opts into URL and ASGI contributions.
|
|
17
|
+
[settings.py](settings.py) composes app selection, additive defaults and a
|
|
18
|
+
declared `CATALOG_` environment overlay; the reviews callback reads the same
|
|
19
|
+
derived selected closure exposed after configure. [Catalog's native config](catalog/apps.py)
|
|
20
|
+
calls `get_user_model()` in ready and reads a models-phase artifact. The project
|
|
21
|
+
[URLconf](urls.py) includes the app's URLconf with Django's native `include()`.
|
|
25
22
|
[Integrations](catalog/integrations.py) render the same deterministic schema
|
|
26
23
|
from the models-phase view and ready-phase native registry. The ready hook derives
|
|
27
24
|
its filename from the populated model label; serving discovers that path from
|
|
28
25
|
the receipt, with no exact-path configuration. [verify.py](verify.py)
|
|
29
|
-
compares those files with serving bytes under a receipt lease
|
|
30
|
-
`/catalog/items
|
|
31
|
-
The schema is plain SDL-like text; it needs no GraphQL dependency.
|
|
26
|
+
compares those files with serving bytes under a receipt lease and exercises
|
|
27
|
+
`/catalog/items/`. The schema is plain SDL-like text; it needs no GraphQL dependency.
|
|
32
28
|
|
|
33
29
|
`manage.py runserver` uses the managed native Django reload loop. Changes to model
|
|
34
30
|
state still require reviewed native migrations. Generated output and SQLite data
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Native lifecycle
|
|
1
|
+
"""Native lifecycle declarations for the catalog app."""
|
|
2
2
|
|
|
3
3
|
from django.apps import AppConfig
|
|
4
4
|
|
|
@@ -6,8 +6,6 @@ from django.apps import AppConfig
|
|
|
6
6
|
class Config(AppConfig):
|
|
7
7
|
name = "catalog"
|
|
8
8
|
requires_apps = ("django.contrib.contenttypes", "django.contrib.auth")
|
|
9
|
-
compose_urls = "catalog.urls"
|
|
10
|
-
compose_url_prefix = "catalog/"
|
|
11
9
|
|
|
12
10
|
def ready(self):
|
|
13
11
|
from django.contrib.auth import get_user_model
|
|
@@ -16,9 +14,3 @@ class Config(AppConfig):
|
|
|
16
14
|
|
|
17
15
|
assert get_user_model()._meta.label == "auth.User"
|
|
18
16
|
self.schema = artifact_path("exports/models.graphql").read_bytes()
|
|
19
|
-
|
|
20
|
-
def compose_asgi(self):
|
|
21
|
-
from catalog.transport import lifespan, status
|
|
22
|
-
from django_compose.asgi import AsgiContribution
|
|
23
|
-
|
|
24
|
-
return AsgiContribution(http_mounts={"/status": status}, lifespans=(lifespan,))
|
|
@@ -8,7 +8,6 @@ from django_compose.conf import configure
|
|
|
8
8
|
BASE_DIR = Path(__file__).resolve().parent
|
|
9
9
|
SECRET_KEY = os.environ.get("SHOP_SECRET_KEY", "local-example-only")
|
|
10
10
|
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "shop.sqlite3"}}
|
|
11
|
-
DATABASES["reporting"] = {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "reporting.sqlite3"}
|
|
12
11
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
13
12
|
COMPOSE_OUTPUT_DIR = BASE_DIR / "runtime"
|
|
14
13
|
COMPOSE_OUTPUT_MODULE = "runtime"
|
|
@@ -16,7 +15,6 @@ COMPOSE_OUTPUT_MODULE = "runtime"
|
|
|
16
15
|
INSTALLED_APPS = ["reviews"]
|
|
17
16
|
COMPOSE_COMPONENT_GROUP = "compose.example"
|
|
18
17
|
COMPOSE_ENV_PREFIXES = ("CATALOG_",)
|
|
19
|
-
COMPOSE_COMMAND_CONTEXT = ("contexts.command_context",)
|
|
20
18
|
COMPOSE_INTEGRATIONS = ("catalog.integrations.ModelSchema", "catalog.integrations.ReadySchema")
|
|
21
19
|
COMPOSE_EXTERNAL_ARTIFACT_ROOTS = ("exports",)
|
|
22
20
|
ROOT_URLCONF = "urls"
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"""Check the same plain Django example from a checkout or installed distribution."""
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Composed models and verified-output readers import only after native setup.
|
|
4
4
|
# ruff: noqa: E402
|
|
5
|
-
import asyncio
|
|
6
5
|
import os
|
|
7
6
|
|
|
8
7
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
|
|
@@ -11,32 +10,14 @@ import django
|
|
|
11
10
|
|
|
12
11
|
django.setup()
|
|
13
12
|
|
|
14
|
-
from asgiref.testing import ApplicationCommunicator
|
|
15
13
|
from catalog.schema import schema
|
|
16
|
-
from catalog.transport import EVENTS
|
|
17
14
|
from django.apps import apps
|
|
18
15
|
from django.conf import settings
|
|
19
16
|
from django.test import Client
|
|
20
17
|
|
|
21
|
-
from django_compose.asgi import application
|
|
22
18
|
from django_compose.components import installed_components
|
|
23
19
|
from django_compose.serving import artifact_path, receipt_lease, verified_receipt
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
async def transports():
|
|
27
|
-
http = ApplicationCommunicator(application, {"type": "http", "path": "/status/live", "root_path": ""})
|
|
28
|
-
assert (await http.receive_output())["status"] == 200
|
|
29
|
-
assert (await http.receive_output())["body"] == b"catalog ready"
|
|
30
|
-
await http.wait()
|
|
31
|
-
lifespan = ApplicationCommunicator(application, {"type": "lifespan"})
|
|
32
|
-
await lifespan.send_input({"type": "lifespan.startup"})
|
|
33
|
-
assert (await lifespan.receive_output())["type"] == "lifespan.startup.complete"
|
|
34
|
-
await lifespan.send_input({"type": "lifespan.shutdown"})
|
|
35
|
-
assert (await lifespan.receive_output())["type"] == "lifespan.shutdown.complete"
|
|
36
|
-
await lifespan.wait()
|
|
37
|
-
assert EVENTS == ["startup", "shutdown"]
|
|
38
|
-
|
|
39
|
-
|
|
40
21
|
Item = apps.get_model("catalog", "Item")
|
|
41
22
|
assert not Item._meta.abstract
|
|
42
23
|
assert Item.schema_name == "Item"
|
|
@@ -61,5 +42,4 @@ with receipt_lease() as receipt:
|
|
|
61
42
|
assert artifact_path(ready_paths[0]).read_bytes() == expected
|
|
62
43
|
assert apps.get_app_config("catalog").schema == expected
|
|
63
44
|
assert Client().get("/catalog/items/").status_code == 200
|
|
64
|
-
|
|
65
|
-
print("Installed app closure, ready callbacks, URL/ASGI/lifespan and both schema phases agree.")
|
|
45
|
+
print("Installed app closure, ready callbacks, native URL routing and both schema phases agree.")
|
|
@@ -439,9 +439,6 @@ assert Item.objects.get(pk=item.pk).rating == 5
|
|
|
439
439
|
"""
|
|
440
440
|
run([str(python), "-c", cold], cwd=host, env=environment)
|
|
441
441
|
run([str(python), "verify.py"], cwd=host, env=environment)
|
|
442
|
-
for arguments, expected in (([], "default"), (["--database", "reporting"], "reporting")):
|
|
443
|
-
result = run([str(python), "manage.py", "verify_context", *arguments], cwd=host, env=environment)
|
|
444
|
-
assert result.strip() == expected, result
|
|
445
442
|
history = digest(host / "runtime/catalog/migrations")
|
|
446
443
|
(host / "runtime/keep.txt").write_text("Unowned file\n")
|
|
447
444
|
models = host / "runtime/catalog/models.py"
|
|
@@ -6,7 +6,6 @@ from django.apps import AppConfig
|
|
|
6
6
|
from django.conf import settings
|
|
7
7
|
from django.core.exceptions import ImproperlyConfigured
|
|
8
8
|
|
|
9
|
-
from django_compose import checks # noqa: F401 -- register deferred native system checks
|
|
10
9
|
from django_compose.serving import _close_startup_verification, _finish_startup_verification, mode, verify
|
|
11
10
|
from django_compose.snapshot import Snapshot
|
|
12
11
|
|
{django_compose-0.1.0.dev8 → django_compose-0.1.0.dev9}/src/django_compose/management/__init__.py
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Native Django dispatch with composition and
|
|
1
|
+
"""Native Django dispatch with composition-mode selection and the reloader parent."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -8,17 +8,13 @@ import signal
|
|
|
8
8
|
import subprocess
|
|
9
9
|
import sys
|
|
10
10
|
import tempfile
|
|
11
|
-
from contextlib import ExitStack
|
|
12
|
-
from types import MappingProxyType
|
|
13
11
|
from typing import Any
|
|
14
12
|
|
|
15
|
-
from django.apps import apps
|
|
16
13
|
from django.conf import settings
|
|
17
14
|
from django.core.exceptions import ImproperlyConfigured
|
|
18
15
|
from django.core.management import ManagementUtility
|
|
19
16
|
from django.core.management.base import CommandError, handle_default_options
|
|
20
17
|
from django.utils import autoreload
|
|
21
|
-
from django.utils.module_loading import import_string
|
|
22
18
|
|
|
23
19
|
from django_compose.autoreload import inputs, report_inputs, write_report
|
|
24
20
|
|
|
@@ -40,51 +36,6 @@ def require_serving_mode() -> None:
|
|
|
40
36
|
raise CommandError("Migration commands require serving mode; unset DJANGO_COMPOSE_MODE")
|
|
41
37
|
|
|
42
38
|
|
|
43
|
-
class _Dispatch:
|
|
44
|
-
def __init__(self, command: Any) -> None:
|
|
45
|
-
self.command = command
|
|
46
|
-
|
|
47
|
-
def __getattr__(self, name: str) -> Any:
|
|
48
|
-
return getattr(self.command, name)
|
|
49
|
-
|
|
50
|
-
def run_from_argv(self, argv: list[str]) -> Any:
|
|
51
|
-
"""Adapt native execute after parsing, retaining the winning argv dispatcher.
|
|
52
|
-
|
|
53
|
-
Custom run_from_argv implementations must call self.execute to participate.
|
|
54
|
-
Factories receive command, original argv and read-only shallow-copied options.
|
|
55
|
-
The native dispatcher continues to own parsing, errors and connection cleanup.
|
|
56
|
-
"""
|
|
57
|
-
original_execute = self.command.execute
|
|
58
|
-
missing = object()
|
|
59
|
-
previous = vars(self.command).get("execute", missing)
|
|
60
|
-
original_argv = tuple(argv)
|
|
61
|
-
|
|
62
|
-
def execute(*args: Any, **options: Any) -> Any:
|
|
63
|
-
with ExitStack() as stack:
|
|
64
|
-
# runserver recovery fabricates ready flags, but not ready_event.
|
|
65
|
-
if apps.ready_event.is_set():
|
|
66
|
-
parsed_options = MappingProxyType(options.copy())
|
|
67
|
-
for dotted in getattr(settings, "COMPOSE_COMMAND_CONTEXT", ()):
|
|
68
|
-
stack.enter_context(
|
|
69
|
-
import_string(dotted)(original_argv[1], original_argv, parsed_options)
|
|
70
|
-
)
|
|
71
|
-
return original_execute(*args, **options)
|
|
72
|
-
|
|
73
|
-
self.command.execute = execute
|
|
74
|
-
try:
|
|
75
|
-
return self.command.run_from_argv(argv)
|
|
76
|
-
finally:
|
|
77
|
-
if previous is missing:
|
|
78
|
-
del self.command.execute
|
|
79
|
-
else:
|
|
80
|
-
self.command.execute = previous
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class _Utility(ManagementUtility):
|
|
84
|
-
def fetch_command(self, subcommand: str) -> Any:
|
|
85
|
-
return _Dispatch(super().fetch_command(subcommand))
|
|
86
|
-
|
|
87
|
-
|
|
88
39
|
def _default_options(arguments: list[str]) -> Any:
|
|
89
40
|
from django_compose.management.commands.compose import Command
|
|
90
41
|
|
|
@@ -161,8 +112,16 @@ def _parent(arguments: list[str]) -> None:
|
|
|
161
112
|
raise SystemExit(code)
|
|
162
113
|
|
|
163
114
|
|
|
164
|
-
def execute(
|
|
165
|
-
|
|
115
|
+
def execute(
|
|
116
|
+
argv: list[str] | None = None, *, utility_class: type[ManagementUtility] = ManagementUtility
|
|
117
|
+
) -> None:
|
|
118
|
+
"""Drop-in management entrypoint retaining Django's native setup policy.
|
|
119
|
+
|
|
120
|
+
Dispatch goes through ``utility_class``, Django's native ManagementUtility
|
|
121
|
+
by default. A project wraps command execution by supplying its own subclass;
|
|
122
|
+
django-compose adds no command middleware. The reloader parent's compose
|
|
123
|
+
subprocess always uses the default dispatcher.
|
|
124
|
+
"""
|
|
166
125
|
arguments = list(sys.argv if argv is None else argv)
|
|
167
126
|
command = arguments[1] if len(arguments) > 1 else "help"
|
|
168
127
|
if command in MIGRATION_COMMANDS:
|
|
@@ -213,7 +172,7 @@ def execute(argv: list[str] | None = None) -> None:
|
|
|
213
172
|
print(f"Composition lock: {settings.COMPOSE_OUTPUT_DIR}/.compose.lock")
|
|
214
173
|
print("Composition is current.")
|
|
215
174
|
return
|
|
216
|
-
|
|
175
|
+
utility_class(arguments).execute()
|
|
217
176
|
finally:
|
|
218
177
|
try:
|
|
219
178
|
_fallback_inputs()
|
|
@@ -23,9 +23,7 @@ from django_compose.sources import SourceResolver
|
|
|
23
23
|
COMPILER = "django-compose:2"
|
|
24
24
|
DEFAULT_EXCLUDES = ("**/__pycache__/**", "**/migrations/**", "**/tests/**")
|
|
25
25
|
|
|
26
|
-
NON_INPUT_SETTINGS = frozenset(
|
|
27
|
-
{"COMPOSE_ROOTS", "COMPOSE_SNAPSHOT", "COMPOSE_CLOSURE", "COMPOSE_COMMAND_CONTEXT"}
|
|
28
|
-
)
|
|
26
|
+
NON_INPUT_SETTINGS = frozenset({"COMPOSE_ROOTS", "COMPOSE_SNAPSHOT", "COMPOSE_CLOSURE"})
|
|
29
27
|
STRUCTURAL_SETTINGS = frozenset(
|
|
30
28
|
{
|
|
31
29
|
"INSTALLED_APPS",
|
|
@@ -206,6 +204,11 @@ def snapshot(
|
|
|
206
204
|
"COMPOSE_TRANSITION_SOURCE is no longer supported; review pending schema and data work "
|
|
207
205
|
"and author native project migrations before upgrading"
|
|
208
206
|
)
|
|
207
|
+
if "COMPOSE_COMMAND_CONTEXT" in values:
|
|
208
|
+
raise ImproperlyConfigured(
|
|
209
|
+
"COMPOSE_COMMAND_CONTEXT is no longer supported; wrap command execution through "
|
|
210
|
+
"execute(..., utility_class=...) with a native ManagementUtility subclass"
|
|
211
|
+
)
|
|
209
212
|
normalized = app_entries(entries)
|
|
210
213
|
positions = {entry.name: index for index, entry in enumerate(normalized)}
|
|
211
214
|
edges = {} if dependencies is None else dependencies
|
|
@@ -44,7 +44,7 @@ class BlockModels:
|
|
|
44
44
|
raise AssertionError(fullname)
|
|
45
45
|
sys.meta_path.insert(0, BlockModels())
|
|
46
46
|
import importlib
|
|
47
|
-
for name in ('snapshot', 'serving', 'history', 'components', 'conf', 'autoreload', '
|
|
47
|
+
for name in ('snapshot', 'serving', 'history', 'components', 'conf', 'autoreload', 'apps'):
|
|
48
48
|
importlib.import_module('django_compose.' + name)
|
|
49
49
|
from django.apps import apps
|
|
50
50
|
assert not apps.apps_ready
|
|
@@ -58,7 +58,7 @@ assert not apps.apps_ready
|
|
|
58
58
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
def
|
|
61
|
+
def test_phase_two_modules_use_native_population(tmp_path):
|
|
62
62
|
from pathlib import Path
|
|
63
63
|
|
|
64
64
|
(tmp_path / "probe").mkdir()
|
|
@@ -74,12 +74,9 @@ class Config(AppConfig):
|
|
|
74
74
|
importlib.import_module("django_compose." + name)
|
|
75
75
|
""")
|
|
76
76
|
script = """from django.conf import settings
|
|
77
|
-
settings.configure(INSTALLED_APPS=["probe.apps.Config"], SECRET_KEY="boundary"
|
|
78
|
-
ROOT_URLCONF="django_compose.urls")
|
|
77
|
+
settings.configure(INSTALLED_APPS=["probe.apps.Config"], SECRET_KEY="boundary")
|
|
79
78
|
import django
|
|
80
79
|
django.setup()
|
|
81
|
-
import django_compose.urls
|
|
82
|
-
import django_compose.asgi
|
|
83
80
|
from django.apps import apps
|
|
84
81
|
assert apps.ready
|
|
85
82
|
"""
|
|
@@ -93,19 +90,11 @@ assert apps.ready
|
|
|
93
90
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
94
91
|
|
|
95
92
|
|
|
96
|
-
def
|
|
93
|
+
def test_distribution_has_no_consumer_vocabulary():
|
|
97
94
|
from pathlib import Path
|
|
98
95
|
|
|
99
96
|
root = Path(__file__).resolve().parents[1] / "src/django_compose"
|
|
100
97
|
assert (root / "__init__.py").read_bytes() == b""
|
|
101
|
-
# 2026-10-29: serialized historical migrations retain this native attribute
|
|
102
|
-
# fallback until a verified consumer-history cutoff permits its removal.
|
|
103
|
-
allowed = {
|
|
104
|
-
'"""Read only the two historical Angee spellings needed for adoption."""',
|
|
105
|
-
'return getattr(migration, f"compose_{name}", getattr(migration, f"angee_{name}", None))',
|
|
106
|
-
'_LEGACY_FOOTER = b"# ANGEE MATERIALIZED MIGRATION - DO NOT EDIT"',
|
|
107
|
-
}
|
|
108
98
|
for path in sorted(root.rglob("*.py")):
|
|
109
99
|
for line in path.read_text().splitlines():
|
|
110
|
-
|
|
111
|
-
assert path.name == "migrations.py" and line.strip() in allowed, (path, line)
|
|
100
|
+
assert "angee" not in line.lower() and '"web"' not in line and "'web'" not in line, (path, line)
|
|
@@ -861,3 +861,11 @@ def test_removed_transition_setting_fails_before_output_verification(project, va
|
|
|
861
861
|
namespace["COMPOSE_TRANSITION_SOURCE"] = value
|
|
862
862
|
with pytest.raises(ImproperlyConfigured, match="native project migrations"):
|
|
863
863
|
conf.configure(namespace)
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
@pytest.mark.parametrize("value", ((), ["project.contexts.first"], None))
|
|
867
|
+
def test_removed_command_context_setting_fails_before_output_verification(project, value):
|
|
868
|
+
_, namespace = project
|
|
869
|
+
namespace["COMPOSE_COMMAND_CONTEXT"] = value
|
|
870
|
+
with pytest.raises(ImproperlyConfigured, match="utility_class"):
|
|
871
|
+
conf.configure(namespace)
|