django-compose 0.1.0.dev7__tar.gz → 0.1.0.dev8__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.dev7 → django_compose-0.1.0.dev8}/AGENTS.md +1 -1
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/CHANGELOG.md +9 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/CONTRIBUTING.md +4 -1
- django_compose-0.1.0.dev8/PKG-INFO +102 -0
- django_compose-0.1.0.dev8/README.md +80 -0
- django_compose-0.1.0.dev8/docs/README.md +34 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/ROADMAP.md +3 -1
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/SPEC.md +23 -120
- django_compose-0.1.0.dev8/docs/api.md +143 -0
- django_compose-0.1.0.dev8/docs/configuration.md +327 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/dependencies.md +1 -1
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/migrations.md +45 -157
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/packaging.md +19 -9
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/proposals/README.md +1 -1
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/provisioning.md +2 -2
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/quickstart.md +7 -2
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/pyproject.toml +1 -1
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/scripts/check_distribution.py +54 -69
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/apps.py +2 -6
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/build.py +0 -5
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/__init__.py +0 -1
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/check_migrations.py +3 -4
- django_compose-0.1.0.dev8/src/django_compose/management/commands/makemigrations.py +18 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/reset_migration_history.py +1 -2
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/migration_imports.py +19 -18
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/migrations.py +29 -581
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/snapshot.py +8 -113
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_bootstrap.py +2 -2
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_conf.py +8 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_history.py +2 -16
- django_compose-0.1.0.dev8/tests/test_initial_history.py +74 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_migration_imports.py +79 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_migration_scaffold.py +13 -0
- django_compose-0.1.0.dev8/tests/test_migrations.py +165 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_migrations_guards.py +10 -120
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_snapshot.py +31 -154
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/uv.lock +1 -1
- django_compose-0.1.0.dev7/PKG-INFO +0 -98
- django_compose-0.1.0.dev7/README.md +0 -76
- django_compose-0.1.0.dev7/docs/README.md +0 -102
- django_compose-0.1.0.dev7/docs/configuration.md +0 -390
- django_compose-0.1.0.dev7/docs/proposals/0003-existing-baseline-adoption.md +0 -32
- django_compose-0.1.0.dev7/src/django_compose/management/commands/adopt_transition.py +0 -41
- django_compose-0.1.0.dev7/src/django_compose/management/commands/makemigrations.py +0 -236
- django_compose-0.1.0.dev7/tests/test_baseline_adoption.py +0 -530
- django_compose-0.1.0.dev7/tests/test_initial_history.py +0 -752
- django_compose-0.1.0.dev7/tests/test_migrations.py +0 -732
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/.gitignore +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/COPYING +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/LICENSE +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/Makefile +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/NOTICE +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/components.md +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/extensions.md +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/models.md +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/proposals/0001-native-url-collisions.md +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/docs/proposals/0002-supplied-distribution-metadata.md +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/.gitignore +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/README.md +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/apps.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/autoconfig.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/integrations.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/management/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/management/commands/verify_context.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/models.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/pyproject.toml +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/schema.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/transport.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/catalog/urls.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/contexts.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/manage.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/reviews/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/reviews/apps.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/reviews/autoconfig.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/reviews/models.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/reviews/pyproject.toml +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/settings.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/urls.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/examples/shop/verify.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/__main__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/artifacts.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/asgi.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/autoreload.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/checks.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/cli.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/components.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/conf.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/declarations.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/history.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/compose.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/migrate.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/provision.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/management/commands/retire_history.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/model_composition.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/models.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/provision.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/py.typed +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/rendering.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/serving.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/sources.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/typing.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/src/django_compose/urls.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/core_fixtures/__init__.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_artifacts.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_asgi.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_autoreload.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_boundaries.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_command_context.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_components.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_integrations.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_launcher.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_migrations_postgres.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_models.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_provision.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_provision_postgres.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_sources.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_startup.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_typing.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/test_urls.py +0 -0
- {django_compose-0.1.0.dev7 → django_compose-0.1.0.dev8}/tests/typing_fixtures/__init__.py +0 -0
|
@@ -6,7 +6,7 @@ package; this package never imports a consumer framework, host, or product.
|
|
|
6
6
|
|
|
7
7
|
Find the owner first. Django owns application identity and population, model
|
|
8
8
|
construction, fields, managers, migration state, execution, routing, and history.
|
|
9
|
-
This package owns composition, deterministic emission,
|
|
9
|
+
This package owns composition, deterministic emission, native history retention
|
|
10
10
|
and verified database preparation. Do not add parallel registries or parsers.
|
|
11
11
|
|
|
12
12
|
Keep entrypoints thin, names consistent, and policy on the owning object.
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0.dev8
|
|
4
|
+
|
|
5
|
+
- Replace reusable transition discovery, binding, baseline/adoption and sealing
|
|
6
|
+
with ordinary project-authored Django migrations. Preserve existing native
|
|
7
|
+
history and independent destructive-change/import-audit protections. This is
|
|
8
|
+
an explicit [prerelease API cutoff](docs/migrations.md#upgrade-from-the-removed-prerelease-protocol).
|
|
9
|
+
- Keep native Watchman daemon acceptance and a shared mandatory PostgreSQL
|
|
10
|
+
CI/release gate open for the stable 0.1.0 release.
|
|
11
|
+
|
|
3
12
|
## 0.1.0.dev7
|
|
4
13
|
|
|
5
14
|
- Add explicit `adopt_transition` authoring for a declared transition satisfied by
|
|
@@ -45,7 +45,7 @@ archives to PyPI when explicitly dispatched or triggered by a version tag.
|
|
|
45
45
|
Django owns app identity/population, model construction, fields, managers, ORM,
|
|
46
46
|
migration state and execution. Extend those native contracts instead of adding
|
|
47
47
|
parallel registries, parsers or lifecycle systems. django-compose owns only the
|
|
48
|
-
composition, deterministic output,
|
|
48
|
+
composition, deterministic output, native history-retention seams and verified
|
|
49
49
|
database preparation through native app hooks.
|
|
50
50
|
|
|
51
51
|
Keep commands and other entrypoints thin. Put a missing rule on its existing
|
|
@@ -71,3 +71,6 @@ independently as well as running the checks. Promote accepted contract changes
|
|
|
71
71
|
into current documentation; proposals record decisions rather than maintaining
|
|
72
72
|
a second API reference. Preserve license notices and attribution when changing
|
|
73
73
|
or distributing code.
|
|
74
|
+
|
|
75
|
+
Native Watchman daemon acceptance and a shared mandatory PostgreSQL CI/release
|
|
76
|
+
gate remain open; this candidate does not establish release readiness.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: django-compose
|
|
3
|
+
Version: 0.1.0.dev8
|
|
4
|
+
Summary: Compose reusable Django apps into a runnable project.
|
|
5
|
+
Project-URL: Source, https://github.com/ang-ee/django-compose
|
|
6
|
+
Project-URL: Documentation, https://github.com/ang-ee/django-compose/tree/main/docs
|
|
7
|
+
Project-URL: Issues, https://github.com/ang-ee/django-compose/issues
|
|
8
|
+
Author-email: "Angee, Inc." <hi@angee.ai>
|
|
9
|
+
License-Expression: LGPL-3.0-or-later
|
|
10
|
+
License-File: COPYING
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Requires-Python: >=3.14
|
|
14
|
+
Requires-Dist: django-yamlconf>=1.5
|
|
15
|
+
Requires-Dist: django<6.2,>=6.1.2
|
|
16
|
+
Requires-Dist: packaging>=26
|
|
17
|
+
Provides-Extra: typing
|
|
18
|
+
Requires-Dist: angee-django-stubs-ext==6.1.2; extra == 'typing'
|
|
19
|
+
Requires-Dist: angee-django-stubs[compatible-mypy]==6.1.2.post3; extra == 'typing'
|
|
20
|
+
Requires-Dist: angee-mypy==2.1.0; extra == 'typing'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# django-compose
|
|
24
|
+
|
|
25
|
+
Compose reusable Django apps into a runnable project.
|
|
26
|
+
|
|
27
|
+
django-compose generates a project's concrete Django models and app
|
|
28
|
+
configurations from the reusable apps you enable. An app can add fields and
|
|
29
|
+
methods to another app's model, contribute settings, and supply optional build
|
|
30
|
+
or startup hooks.
|
|
31
|
+
|
|
32
|
+
Use it when projects share apps but need different combinations of features.
|
|
33
|
+
Your project selects its root apps in `INSTALLED_APPS`; django-compose includes
|
|
34
|
+
their declared app dependencies. Installing a package alone does not enable it.
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
installed app packages + project settings → compose → Django models and app configs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## One model, two apps
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
# catalog/models.py
|
|
44
|
+
from django.db import models
|
|
45
|
+
from django_compose.models import Composable
|
|
46
|
+
|
|
47
|
+
class Item(Composable, concrete=True):
|
|
48
|
+
title = models.CharField(max_length=100)
|
|
49
|
+
|
|
50
|
+
class Meta:
|
|
51
|
+
abstract = True
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# reviews/models.py
|
|
56
|
+
from django.db import models
|
|
57
|
+
from django_compose.models import Composable
|
|
58
|
+
|
|
59
|
+
class Rating(Composable, extends="catalog.Item"):
|
|
60
|
+
rating = models.PositiveSmallIntegerField(default=0)
|
|
61
|
+
|
|
62
|
+
class Meta:
|
|
63
|
+
abstract = True
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
With both apps enabled, the generated `catalog.Item` has `title` and `rating` in
|
|
67
|
+
one table. `Rating` adds no table of its own. After Django setup, retrieve the
|
|
68
|
+
concrete class with `apps.get_model("catalog", "Item")` and use its normal manager
|
|
69
|
+
and queryset. The source declarations remain abstract.
|
|
70
|
+
|
|
71
|
+
The [model guide](https://github.com/ang-ee/django-compose/blob/main/docs/models.md)
|
|
72
|
+
also covers `inherits` for Django multi-table inheritance and `demands` for
|
|
73
|
+
required ancestors.
|
|
74
|
+
|
|
75
|
+
## How a project uses it
|
|
76
|
+
|
|
77
|
+
Author your Django settings and `manage.py`, call `configure(globals())` at the
|
|
78
|
+
end of settings, and use the django-compose command launcher. In that configured
|
|
79
|
+
project:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
python manage.py compose # Generate models, app configs and declared artifacts
|
|
83
|
+
python manage.py makemigrations # Author ordinary Django migration files
|
|
84
|
+
python manage.py migrate # Apply them to the database
|
|
85
|
+
python manage.py runserver # Run Django's development server
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Django owns the app registry, ORM, managers, querysets and migration history.
|
|
89
|
+
Generated classes import the source apps, so keep their packages installed.
|
|
90
|
+
Rebuild generated code as apps change; preserve and review migration files.
|
|
91
|
+
|
|
92
|
+
## Get started
|
|
93
|
+
|
|
94
|
+
This is a development preview. See [compatibility and platform requirements](https://github.com/ang-ee/django-compose/blob/main/docs/dependencies.md)
|
|
95
|
+
and [installation](https://github.com/ang-ee/django-compose/blob/main/docs/packaging.md).
|
|
96
|
+
|
|
97
|
+
- [Quick start](https://github.com/ang-ee/django-compose/blob/main/docs/quickstart.md): run the SQLite example and query the composed model.
|
|
98
|
+
- [Project setup](https://github.com/ang-ee/django-compose/blob/main/docs/configuration.md): complete settings, launcher and model files.
|
|
99
|
+
- [Public API](https://github.com/ang-ee/django-compose/blob/main/docs/api.md): commands, Python entry points and app hooks.
|
|
100
|
+
- [Documentation](https://github.com/ang-ee/django-compose/blob/main/docs/README.md): guides for apps, settings, migrations and deployment.
|
|
101
|
+
|
|
102
|
+
Licensed under [LGPL-3.0-or-later](https://github.com/ang-ee/django-compose/blob/main/LICENSE).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# django-compose
|
|
2
|
+
|
|
3
|
+
Compose reusable Django apps into a runnable project.
|
|
4
|
+
|
|
5
|
+
django-compose generates a project's concrete Django models and app
|
|
6
|
+
configurations from the reusable apps you enable. An app can add fields and
|
|
7
|
+
methods to another app's model, contribute settings, and supply optional build
|
|
8
|
+
or startup hooks.
|
|
9
|
+
|
|
10
|
+
Use it when projects share apps but need different combinations of features.
|
|
11
|
+
Your project selects its root apps in `INSTALLED_APPS`; django-compose includes
|
|
12
|
+
their declared app dependencies. Installing a package alone does not enable it.
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
installed app packages + project settings → compose → Django models and app configs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## One model, two apps
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
# catalog/models.py
|
|
22
|
+
from django.db import models
|
|
23
|
+
from django_compose.models import Composable
|
|
24
|
+
|
|
25
|
+
class Item(Composable, concrete=True):
|
|
26
|
+
title = models.CharField(max_length=100)
|
|
27
|
+
|
|
28
|
+
class Meta:
|
|
29
|
+
abstract = True
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
# reviews/models.py
|
|
34
|
+
from django.db import models
|
|
35
|
+
from django_compose.models import Composable
|
|
36
|
+
|
|
37
|
+
class Rating(Composable, extends="catalog.Item"):
|
|
38
|
+
rating = models.PositiveSmallIntegerField(default=0)
|
|
39
|
+
|
|
40
|
+
class Meta:
|
|
41
|
+
abstract = True
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
With both apps enabled, the generated `catalog.Item` has `title` and `rating` in
|
|
45
|
+
one table. `Rating` adds no table of its own. After Django setup, retrieve the
|
|
46
|
+
concrete class with `apps.get_model("catalog", "Item")` and use its normal manager
|
|
47
|
+
and queryset. The source declarations remain abstract.
|
|
48
|
+
|
|
49
|
+
The [model guide](https://github.com/ang-ee/django-compose/blob/main/docs/models.md)
|
|
50
|
+
also covers `inherits` for Django multi-table inheritance and `demands` for
|
|
51
|
+
required ancestors.
|
|
52
|
+
|
|
53
|
+
## How a project uses it
|
|
54
|
+
|
|
55
|
+
Author your Django settings and `manage.py`, call `configure(globals())` at the
|
|
56
|
+
end of settings, and use the django-compose command launcher. In that configured
|
|
57
|
+
project:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
python manage.py compose # Generate models, app configs and declared artifacts
|
|
61
|
+
python manage.py makemigrations # Author ordinary Django migration files
|
|
62
|
+
python manage.py migrate # Apply them to the database
|
|
63
|
+
python manage.py runserver # Run Django's development server
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Django owns the app registry, ORM, managers, querysets and migration history.
|
|
67
|
+
Generated classes import the source apps, so keep their packages installed.
|
|
68
|
+
Rebuild generated code as apps change; preserve and review migration files.
|
|
69
|
+
|
|
70
|
+
## Get started
|
|
71
|
+
|
|
72
|
+
This is a development preview. See [compatibility and platform requirements](https://github.com/ang-ee/django-compose/blob/main/docs/dependencies.md)
|
|
73
|
+
and [installation](https://github.com/ang-ee/django-compose/blob/main/docs/packaging.md).
|
|
74
|
+
|
|
75
|
+
- [Quick start](https://github.com/ang-ee/django-compose/blob/main/docs/quickstart.md): run the SQLite example and query the composed model.
|
|
76
|
+
- [Project setup](https://github.com/ang-ee/django-compose/blob/main/docs/configuration.md): complete settings, launcher and model files.
|
|
77
|
+
- [Public API](https://github.com/ang-ee/django-compose/blob/main/docs/api.md): commands, Python entry points and app hooks.
|
|
78
|
+
- [Documentation](https://github.com/ang-ee/django-compose/blob/main/docs/README.md): guides for apps, settings, migrations and deployment.
|
|
79
|
+
|
|
80
|
+
Licensed under [LGPL-3.0-or-later](https://github.com/ang-ee/django-compose/blob/main/LICENSE).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Documentation
|
|
2
|
+
|
|
3
|
+
django-compose builds concrete Django models and app configurations from the
|
|
4
|
+
reusable apps selected by a project. Apps contribute declarations and settings;
|
|
5
|
+
Django supplies the registry, ORM and migrations.
|
|
6
|
+
|
|
7
|
+
## Start here
|
|
8
|
+
|
|
9
|
+
1. [Quick start](quickstart.md) — run the shop example and query a composed model.
|
|
10
|
+
2. [Project setup](configuration.md) — add composition to your own Django project.
|
|
11
|
+
3. [Public API](api.md) — find commands, Python entry points and app hooks.
|
|
12
|
+
|
|
13
|
+
## Guides
|
|
14
|
+
|
|
15
|
+
| I want to… | Read |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| Add fields or behavior from another app | [Model declarations](models.md) |
|
|
18
|
+
| Choose apps and follow their dependencies | [App selection and package metadata](components.md) |
|
|
19
|
+
| Contribute settings or URLs | [Project configuration](configuration.md#app-settings-contributions) |
|
|
20
|
+
| Generate additional files or model metadata | [Build integrations](extensions.md) |
|
|
21
|
+
| Change models, disable apps or maintain history | [Migrations](migrations.md) |
|
|
22
|
+
| Prepare a database and check readiness | [Provisioning](provisioning.md) |
|
|
23
|
+
| Install the package or deploy a composed project | [Installation and deployment](packaging.md) |
|
|
24
|
+
| Check platform support or configure mypy | [Compatibility and typing](dependencies.md) |
|
|
25
|
+
|
|
26
|
+
## Reference and contribution
|
|
27
|
+
|
|
28
|
+
The [contract details](SPEC.md) define validation, ordering and lifecycle rules.
|
|
29
|
+
[Contributing](../CONTRIBUTING.md) covers development and checks;
|
|
30
|
+
the [roadmap](ROADMAP.md) lists open work.
|
|
31
|
+
|
|
32
|
+
These docs describe this checkout. The [changelog](../CHANGELOG.md) identifies
|
|
33
|
+
released changes; use a [local installation](packaging.md#install-locally) for
|
|
34
|
+
features marked **Unreleased**.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Current scope and open work
|
|
2
2
|
|
|
3
|
-
The [API
|
|
3
|
+
The [public API](api.md) describes what is available; the
|
|
4
4
|
[reference](SPEC.md) defines its contracts. Release changes belong in the
|
|
5
5
|
[changelog](../CHANGELOG.md).
|
|
6
6
|
|
|
@@ -13,5 +13,7 @@ Current boundaries and remaining verification:
|
|
|
13
13
|
- StatReloader edit, failure/recovery and file creation/deletion checks have run.
|
|
14
14
|
Watchman adapter tests cover the same declarations; acceptance against a native
|
|
15
15
|
Watchman daemon remains outstanding.
|
|
16
|
+
- CI and publication still need one shared mandatory PostgreSQL check gate and
|
|
17
|
+
exact checked-archive transfer. The migration candidate is not release-ready.
|
|
16
18
|
|
|
17
19
|
Changes to a public contract use the [proposal process](proposals/README.md).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Contract details
|
|
2
2
|
|
|
3
3
|
This is the current contract for django-compose. For a compact map of commands,
|
|
4
|
-
Python entry points and app hooks, start with the [API
|
|
4
|
+
Python entry points and app hooks, start with the [API overview](api.md).
|
|
5
5
|
For runnable examples, use the [quick start](quickstart.md) and
|
|
6
6
|
[project configuration](configuration.md). [Compatibility](dependencies.md)
|
|
7
7
|
defines supported versions and platforms.
|
|
@@ -15,7 +15,7 @@ defines supported versions and platforms.
|
|
|
15
15
|
- [Integration protocols](#integration-protocols)
|
|
16
16
|
- [Generated output and freshness](#generated-output-and-freshness)
|
|
17
17
|
- [Artifact access](#artifact-access)
|
|
18
|
-
- [Native history
|
|
18
|
+
- [Native history](#native-history)
|
|
19
19
|
- [Database preparation and readiness](#database-preparation-and-readiness)
|
|
20
20
|
- [Serving composition](#serving-composition)
|
|
21
21
|
- [Typing and import boundaries](#typing-and-import-boundaries)
|
|
@@ -252,13 +252,12 @@ keep ordering and input ownership in one place. See the
|
|
|
252
252
|
| `COMPOSE_FINGERPRINT_EXCLUDES` | Source exclusion patterns; defaults to `**/tests/**`, `**/migrations/**`, `**/__pycache__/**` |
|
|
253
253
|
| `COMPOSE_FINGERPRINT_SETTINGS` | Additional setting names affecting the build; empty by default |
|
|
254
254
|
| `COMPOSE_EXTERNAL_ARTIFACT_ROOTS` | Permitted integration output directories; empty by default |
|
|
255
|
-
| `COMPOSE_TRANSITION_SOURCE` | Explicit transition declarations or dotted pre-setup-safe callable; omission selects default discovery |
|
|
256
255
|
| `COMPOSE_CLOSURE` | Derived selected Closure, available to contribution callbacks |
|
|
257
256
|
| `COMPOSE_SNAPSHOT` | Derived Snapshot used by lifecycle configurations |
|
|
258
257
|
|
|
259
258
|
Mandatory inputs include resolved app/config identities, source Python and
|
|
260
259
|
extra-glob bytes, selected config MRO implementation modules, integration modules,
|
|
261
|
-
|
|
260
|
+
`DEFAULT_AUTO_FIELD`, `AUTH_USER_MODEL`, authored
|
|
262
261
|
migration mappings, every `COMPOSE_*` value except derived `COMPOSE_ROOTS`,
|
|
263
262
|
`COMPOSE_SNAPSHOT`, `COMPOSE_CLOSURE` and execution-only `COMPOSE_COMMAND_CONTEXT`, and compiler identity. Built-in/frozen config owners use a
|
|
264
263
|
deterministic interpreter implementation/version identity instead of file bytes.
|
|
@@ -284,28 +283,6 @@ RECORD or PEP 610 ownership, with one lazy index per audit. Native app/config
|
|
|
284
283
|
modules are imported to select configurations and must remain safe before Django
|
|
285
284
|
setup. Snapshot and serving do not import the model compiler or execute integrations.
|
|
286
285
|
|
|
287
|
-
Without `COMPOSE_TRANSITION_SOURCE`, each selected app contributes sorted
|
|
288
|
-
`compose_migrations/<label>/<name>.py` files in app order, including numeric
|
|
289
|
-
migration names. The public owner is
|
|
290
|
-
`snapshot.discover_transitions(entries: Iterable[Entry]) -> tuple[Mapping[str, str], ...]`.
|
|
291
|
-
It accepts resolved identities such as `Closure.app_entries`, preserves their
|
|
292
|
-
order, reports watched paths and returns immutable normalized records without
|
|
293
|
-
importing apps or migration modules. Default snapshot discovery calls this same
|
|
294
|
-
function. A settings adapter can use the already resolved `COMPOSE_CLOSURE` during
|
|
295
|
-
an app's `settings(namespace)` callback, annotate copies using owner-declared
|
|
296
|
-
facts, and return concrete `COMPOSE_TRANSITION_SOURCE` records before the snapshot.
|
|
297
|
-
Preserve other records and any explicitly authored replacement source; selecting
|
|
298
|
-
apps again or reading lazy Django settings during configuration is unnecessary.
|
|
299
|
-
An explicit source replaces discovery. Records require
|
|
300
|
-
`declaring_app`, `name`, `app_label` and `module` string keys, and optionally
|
|
301
|
-
`initial_baseline: "satisfied"`; other keys or baseline values are invalid.
|
|
302
|
-
Omission retains strict guard handling. The explicit transition-owner provider
|
|
303
|
-
supplies this assertion; default discovery does not infer it from source modules.
|
|
304
|
-
Modules relative to the declaring app are normalized once. Duplicate
|
|
305
|
-
`<declaring_app>:<name>` origins fail. `Snapshot.transition_records` retains the frozen normalized records;
|
|
306
|
-
`Snapshot.transitions` stores their origin/sha256 pairs. Build and native history
|
|
307
|
-
use the same records.
|
|
308
|
-
|
|
309
286
|
## Setup lifecycle
|
|
310
287
|
|
|
311
288
|
`DJANGO_COMPOSE_MODE` is `write`, `check`, or absent for serving; every other value
|
|
@@ -349,8 +326,8 @@ hooks, and finalizes in the final `ready()` callback:
|
|
|
349
326
|
no mutation.
|
|
350
327
|
|
|
351
328
|
All native `ready()` callbacks see concrete models and models-phase files.
|
|
352
|
-
`BuildComposeConfig.ready()` additionally compares native migration history
|
|
353
|
-
|
|
329
|
+
`BuildComposeConfig.ready()` additionally compares native migration history in
|
|
330
|
+
check mode. Ordinary write composition does not load
|
|
354
331
|
migration history, query a deployment database, author migrations or apply them.
|
|
355
332
|
Native source import hooks still execute as part of Django population.
|
|
356
333
|
|
|
@@ -453,13 +430,13 @@ existing bytes. Preserve native history as explained in [packaging](packaging.md
|
|
|
453
430
|
path and current hash before returning a Path. During build-ready callbacks it
|
|
454
431
|
supports models-phase artifacts before final publication.
|
|
455
432
|
|
|
456
|
-
## Native history
|
|
433
|
+
## Native history
|
|
457
434
|
|
|
458
435
|
For generated labels, history defaults to `<output_module>.<label>.migrations`.
|
|
459
436
|
`serving.migration_modules(authored, receipt, output_module)` derives retained
|
|
460
437
|
defaults from the record, then applies authored overrides, including `None`.
|
|
461
438
|
`HISTORY_LABELS` retains model labels, previous history, on-disk migration
|
|
462
|
-
packages
|
|
439
|
+
packages, minus `RETIRED_LABELS`. History-only configs use
|
|
463
440
|
`django_compose.history.History_<label>`, generated dynamically from retained
|
|
464
441
|
receipt facts; they load no old source models or app lifecycle.
|
|
465
442
|
|
|
@@ -470,87 +447,18 @@ record labels minus retired and snapshot-selected app labels. An enabled app
|
|
|
470
447
|
that loses its last model remains active and yields a native model deletion.
|
|
471
448
|
All package migration comparisons use this state calculation.
|
|
472
449
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
A failed attempt can retry from the same disk history. This is exception safety,
|
|
486
|
-
not crash-atomic publication of multiple files.
|
|
487
|
-
|
|
488
|
-
`TransitionBinding` uses frozen snapshot records by default, or explicit
|
|
489
|
-
`declarations=`. It binds native migration origins `<declaring_app>:<name>` to
|
|
490
|
-
the project's actual graph leaves. Each source provides a native `Migration`
|
|
491
|
-
and a pure `applies(ProjectState) -> bool` guard. Ordinary planning and
|
|
492
|
-
`makemigrations` refuse a pending false guard unless its owner declares `initial_baseline: "satisfied"` and the label acquired
|
|
493
|
-
its first native disk nodes in this successful command's initial-authoring phase,
|
|
494
|
-
including native prerequisite expansion. The assertion means the final-schema
|
|
495
|
-
initial baseline satisfies this transition on every database adopting it,
|
|
496
|
-
including existing rows adopted through native `migrate --fake-initial`. It does
|
|
497
|
-
not assert that the original operations executed. Existing initial-looking
|
|
498
|
-
files, reset-created initials and global read-only checks supply no exemption.
|
|
499
|
-
True guards always retain their operations, including bootstrap and backfill
|
|
500
|
-
work. A false-guard baseline binding substitutes Django's native empty migration
|
|
501
|
-
before downstream graph state calculation. Its materialization footer seals a
|
|
502
|
-
native zero-operation Migration subclass and `compose_initial_baseline =
|
|
503
|
-
"satisfied"`, omitting any source-class state or database lifecycle overrides. This
|
|
504
|
-
durable origin must be retained like any other native history node after its
|
|
505
|
-
source declaration is removed. Its source bytes and source SHA remain unchanged;
|
|
506
|
-
adding the optional declaration does not rewrite or invalidate existing origins.
|
|
507
|
-
Immutable source/body digests, dependencies, `run_before`, `replaces` and complete
|
|
508
|
-
squash chains are preserved. Materialized history remains executable after its
|
|
509
|
-
source declaration is removed. Changed immutable sources, duplicate origins,
|
|
510
|
-
missing prerequisites and cycles fail. Dry-run/check never author history.
|
|
511
|
-
Legacy `angee_origin` and `angee_source_sha256` metadata is read only for
|
|
512
|
-
historical adoption; new metadata uses `compose_origin` and
|
|
513
|
-
`compose_source_sha256`.
|
|
514
|
-
|
|
515
|
-
Explicit existing-baseline adoption uses
|
|
516
|
-
`TransitionBinding.adoption_plan(origin, baseline)` and
|
|
517
|
-
`TransitionBinding.adopt(origin, baseline, *, dry_run=False)`, or the thin
|
|
518
|
-
`adopt_transition DECLARING_APP:NAME --baseline APP_LABEL.MIGRATION_NAME
|
|
519
|
-
[--dry-run]` management command. The selected normalized declaration and source
|
|
520
|
-
SHA must match `COMPOSE_SNAPSHOT.transition_records` and `transitions`, and the
|
|
521
|
-
owner must already assert `initial_baseline: "satisfied"`.
|
|
522
|
-
|
|
523
|
-
The explicit action is the caller's attestation that the named retained initial
|
|
524
|
-
is the baseline covered by that owner assertion. Native graph structure and
|
|
525
|
-
false guards establish the action's scope; they prove neither historical data
|
|
526
|
-
completion nor schema equivalence. The named anchor must be same-target-label,
|
|
527
|
-
retained on disk and active in Django's graph, and an ancestor of the unique
|
|
528
|
-
current target leaf. It must have `Migration.initial is True`, or `initial is
|
|
529
|
-
None` and be a native same-app graph root. This root criterion is conservative
|
|
530
|
-
scope for adoption, not a reimplementation of Django's soft-initial detection;
|
|
531
|
-
`run_before` can affect native graph roots. A true guard either after the named
|
|
532
|
-
anchor or at the resolved binding pre-state refuses adoption. Unrelated current
|
|
533
|
-
model drift remains for ordinary `makemigrations`.
|
|
534
|
-
|
|
535
|
-
Only the selected pending declaration is loaded. Native graph resolution freezes
|
|
536
|
-
its dependency and `run_before` edges; missing or pending explicit prerequisites
|
|
537
|
-
or successors, cycles and ambiguous relevant leaves refuse. Unrelated pending
|
|
538
|
-
sources are not imported or implicitly adopted. The new sealed native empty
|
|
539
|
-
origin depends on the current retained target leaf, preserving existing files.
|
|
540
|
-
The footer retains the existing source/body seals and baseline-satisfaction
|
|
541
|
-
marker, plus `compose_adopted_baseline` (the anchor Node) and
|
|
542
|
-
`compose_adopted_baseline_sha256` (the exact native anchor file hash).
|
|
543
|
-
|
|
544
|
-
`adoption_plan` returns a `TransitionPlan`, or `None` for an exact retained
|
|
545
|
-
adoption. `adopt` returns the authored path tuple, the prospective path tuple
|
|
546
|
-
for dry-run, or an empty tuple for an exact repeat. A repeat validates the sealed
|
|
547
|
-
origin's native empty semantics, selected source, matching anchor and anchor SHA
|
|
548
|
-
without rewriting or rebinding it, including after later native descendants.
|
|
549
|
-
Existing ordinary or first-authoring origins are not silently converted to
|
|
550
|
-
adoptions. Dry-run validates without writes; failed publication removes only
|
|
551
|
-
its newly authored files through the same exclusive rollback owner as normal
|
|
552
|
-
binding. Authoring never queries the database or writes the migration recorder;
|
|
553
|
-
Django's subsequent `migrate` owns application and recording.
|
|
450
|
+
`makemigrations` delegates authoring to Django using the shared drop-guard
|
|
451
|
+
autodetector. Django owns `--check`, `--dry-run`, `--empty`, `--merge`, `--update`,
|
|
452
|
+
serialization and file destinations. There is no custom multi-phase authoring or
|
|
453
|
+
whole-command rollback journal; native command semantics apply. Authoring may
|
|
454
|
+
read routed databases for destructive-change safety, but does not write migration
|
|
455
|
+
recorder rows. Native `migrate` owns application and recording.
|
|
456
|
+
|
|
457
|
+
`migrations.check_native_history(apps, *, labels)` compares native graph state
|
|
458
|
+
with effective composed state without database access. `migrations.history_labels()`
|
|
459
|
+
reads retained labels from the build record. Compiler revision is 2; the receipt
|
|
460
|
+
schema is unchanged. For the prerelease cutoff and retained historical files,
|
|
461
|
+
see [upgrade guidance](migrations.md#upgrade-from-the-removed-prerelease-protocol).
|
|
554
462
|
|
|
555
463
|
`DropGuardAutodetector`, shared by native `makemigrations` and `migrate`, requires
|
|
556
464
|
relevant rows or columns to be empty on every database eligible for the native
|
|
@@ -562,16 +470,11 @@ and unavailable eligible databases cannot prove safety. Explicit integration-own
|
|
|
562
470
|
row exemptions use `MigrationPolicy`. See the [storage proof's supported cases
|
|
563
471
|
and limits](migrations.md#advanced-destructive-changes-and-history-cutoffs).
|
|
564
472
|
|
|
565
|
-
Reusable transition planning remains database-free. It conservatively retains
|
|
566
|
-
feature-dependent aliases when checking the feature could connect, and refuses
|
|
567
|
-
ambiguous shared storage that requires database visibility to resolve. Explicit
|
|
568
|
-
migration authoring, purge and history maintenance use database-aware checks.
|
|
569
|
-
|
|
570
473
|
Retirement requires consistent fully applied history across all configured
|
|
571
474
|
migration-relevant aliases and refuses retained incoming cross-app dependencies.
|
|
572
475
|
The alias scope includes native data-operation routing hints; custom database
|
|
573
476
|
behavior that cannot establish a narrower scope requires all configured aliases.
|
|
574
|
-
Optional purge authors/applies a final deletion
|
|
477
|
+
Optional purge authors/applies a final native deletion migration on that same alias
|
|
575
478
|
scope; purge alone is not retirement. Successful retirement updates the record;
|
|
576
479
|
the next compose removes the history-only config. Databases absent from command
|
|
577
480
|
settings lie outside that proof. Guarded history reset additionally requires a
|
|
@@ -579,9 +482,9 @@ fully applied, model-clean graph and uses transactional recorder changes with
|
|
|
579
482
|
filesystem rollback preserving original bytes and permissions. Normal build and
|
|
580
483
|
clean never reset history.
|
|
581
484
|
|
|
582
|
-
`check_migrations` checks native state
|
|
485
|
+
`check_migrations` checks native state.
|
|
583
486
|
`check_migrations --imports` statically audits selected migration sources,
|
|
584
|
-
authored mappings, project
|
|
487
|
+
authored mappings, project and historical helpers and literal dynamic imports. It
|
|
585
488
|
classifies exact distribution providers, interpreter-owned modules, app/project
|
|
586
489
|
sources and unresolved/unsupported imports. Native loader diagnostics may import
|
|
587
490
|
ordinary migration modules, but the audit issues no database queries and applies
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Public API overview
|
|
2
|
+
|
|
3
|
+
django-compose lets reusable Django apps contribute to the same concrete models,
|
|
4
|
+
settings and optional generated files. The project selects apps in `INSTALLED_APPS`;
|
|
5
|
+
composition builds a project-owned package that uses Django's registry, ORM and
|
|
6
|
+
migration history. Django still owns fields, managers, routing and execution.
|
|
7
|
+
|
|
8
|
+
Use the [quick start](quickstart.md) for a runnable example and
|
|
9
|
+
[project configuration](configuration.md) to adopt it. This page maps public
|
|
10
|
+
entry points to their guides; [contract details](SPEC.md) own validation and
|
|
11
|
+
lifecycle rules. Python module names below are relative to `django_compose`.
|
|
12
|
+
|
|
13
|
+
## Set up and run a project
|
|
14
|
+
|
|
15
|
+
| API | Purpose |
|
|
16
|
+
| --- | --- |
|
|
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 |
|
|
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
|
+
|
|
21
|
+
The launcher exposes these Django management commands:
|
|
22
|
+
|
|
23
|
+
| Command | Purpose | Guide |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `compose` | Generate output; `--check` verifies output/history without writes; `--if-stale` skips a current build | [Lifecycle](SPEC.md#setup-lifecycle) |
|
|
26
|
+
| `makemigrations`, `migrate` | Author and apply ordinary Django migrations | [Migrations](migrations.md) |
|
|
27
|
+
| `runserver` | Compose before Django's development-server reloads | [Development](configuration.md#serve-the-project) |
|
|
28
|
+
| `provision` | Apply migrations and app preparation hooks; `--check` verifies readiness | [Provisioning](provisioning.md) |
|
|
29
|
+
| `check_migrations` | Compare models/history; `--imports` audits retained Python dependencies | [History checks](migrations.md#disable-delete-or-uninstall) |
|
|
30
|
+
| `retire_history`, `reset_migration_history` | Explicit, guarded history maintenance | [Advanced migrations](migrations.md#advanced-destructive-changes-and-history-cutoffs) |
|
|
31
|
+
|
|
32
|
+
Build before serving; the serving process verifies output rather than rebuilding.
|
|
33
|
+
`DJANGO_COMPOSE_MODE` is `write`, `check`, or absent for serving. Use the launcher
|
|
34
|
+
to select it; migration commands require it absent. Source packages remain runtime
|
|
35
|
+
dependencies. Generated files are rebuildable; migrations are durable history.
|
|
36
|
+
See [deployment](packaging.md) for artifact preparation and verification.
|
|
37
|
+
|
|
38
|
+
## Declare models
|
|
39
|
+
|
|
40
|
+
Import `Composable` from [`django_compose.models`](../src/django_compose/models.py).
|
|
41
|
+
Every declaration explicitly sets `Meta.abstract = True` and uses Django's normal
|
|
42
|
+
fields, managers and methods. Its class keywords express composition intent:
|
|
43
|
+
|
|
44
|
+
| Keyword | Purpose | Example |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `concrete=True` | Generate a concrete model identity and table | [Own identity](models.md#give-a-model-its-own-identity) |
|
|
47
|
+
| `extends="catalog.Item"` | Contribute fields and behavior to another model | [Extension](models.md#extend-that-model-in-another-app) |
|
|
48
|
+
| `inherits="catalog.Item"` | Generate a multi-table child; concrete is implied | [Child model](models.md#create-a-child-with-its-own-table) |
|
|
49
|
+
| `demands="catalog.Item"` | Require a concrete ancestor in descendants | [Ancestor requirement](models.md#demand-a-concrete-ancestor) |
|
|
50
|
+
|
|
51
|
+
`concrete`, `extends` and `inherits` are mutually exclusive; only `demands`
|
|
52
|
+
propagates through abstract bases. Use [Django's app registry and lazy relations](models.md#use-the-generated-model-and-lazy-relations)
|
|
53
|
+
to work with generated models. See [model contracts](SPEC.md#model-declarations)
|
|
54
|
+
for ordering and collision rules.
|
|
55
|
+
|
|
56
|
+
## Select apps and inspect packages
|
|
57
|
+
|
|
58
|
+
These APIs live in [`django_compose.components`](../src/django_compose/components.py).
|
|
59
|
+
They do not install packages or read project settings.
|
|
60
|
+
|
|
61
|
+
| API | Result / purpose |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `enabled_apps(roots, *, group=None)` | Immutable `Closure` of dependency-ordered apps; without a group, follow only declared `AppConfig.requires_apps` dependencies |
|
|
64
|
+
| `inspect_apps(roots, *, group=None, timeout=30.0)` | Detached JSON-compatible `AppSelection` from a fresh interpreter, safe to call from an already running application |
|
|
65
|
+
| `installed_components(group)` | Read-only `InstalledComponents` index of installed native distribution metadata, without importing apps |
|
|
66
|
+
| `index_components(distributions, *, group)` | The same index for supplied `importlib.metadata.Distribution` objects, including separately prepared source metadata |
|
|
67
|
+
| `active_requirements(requirements)` | Native `Requirement` objects active on this platform with `extra=""` |
|
|
68
|
+
| `InstalledComponents.active_requirements(provider)` | Active requirements for a canonical distribution name in the index |
|
|
69
|
+
|
|
70
|
+
`Closure` exposes native identity `app_entries`, `entries` strings, selected
|
|
71
|
+
`app_configs`, `roots`, dependency-only `required`, `components` and `dependencies`.
|
|
72
|
+
`AppSelection` contains detached identity dictionaries and the same selection facts
|
|
73
|
+
without native configs. `InstalledComponents` exposes `distributions`, `entry_points`
|
|
74
|
+
and `providers`, retaining native metadata objects. Indexing does not activate apps;
|
|
75
|
+
selection imports native app/config modules, which must be safe before Django setup.
|
|
76
|
+
Installing a package or extra alone never enables an app.
|
|
77
|
+
|
|
78
|
+
See [package declarations and selection](components.md),
|
|
79
|
+
[supplied metadata](components.md#inspect-package-metadata-without-importing-apps)
|
|
80
|
+
and [selection contracts](SPEC.md#application-selection).
|
|
81
|
+
|
|
82
|
+
`django-compose inspect-apps [--group GROUP] [--timeout SECONDS] [APP_ENTRY ...]`
|
|
83
|
+
(or `python -m django_compose inspect-apps ...`) prints `AppSelection` JSON without
|
|
84
|
+
loading project settings. It is a **standalone command**, unavailable through
|
|
85
|
+
`manage.py`; see [inspection](components.md#inspect-a-selection-from-a-running-application).
|
|
86
|
+
|
|
87
|
+
## Contribute app behavior
|
|
88
|
+
|
|
89
|
+
| Declaration / API | Contribution | Guide |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| `AppConfig.requires_apps` | App dependencies declared for composition | [Selection rules](components.md#dependency-and-configuration-rules) |
|
|
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
|
+
| `AppConfig.compose_provision(context)` | Prepare the database after migrations using `provision.ProvisionContext` and its `call()` helper | [Provisioning](provisioning.md) |
|
|
96
|
+
| `COMPOSE_INTEGRATIONS` | Dotted classes implementing build protocols below | [Build integrations](extensions.md#supported-protocols) |
|
|
97
|
+
|
|
98
|
+
URL and ASGI modules require completed `django.setup()`. Settings contributions
|
|
99
|
+
run before app population; integrations run during build. Ordinary model behavior
|
|
100
|
+
belongs in abstract model bases. The [integration protocols](SPEC.md#integration-protocols)
|
|
101
|
+
in [`django_compose.declarations`](../src/django_compose/declarations.py) are:
|
|
102
|
+
|
|
103
|
+
- `ModelDeclarationHook.model_declaration(composition, source)` returns a literal
|
|
104
|
+
`ModelDeclaration(attributes=..., meta_options=...)` using `DeclarationValue` values.
|
|
105
|
+
- `ArtifactHook` declares `external_root`, `phase` and `render(composition, models)`.
|
|
106
|
+
Models-phase hooks receive `ModelsView`; ready-phase hooks receive Django's registry.
|
|
107
|
+
- `MigrationPolicy.retired_primary_keys(model, alias)` supplies explicit exemptions
|
|
108
|
+
to destructive-change checks.
|
|
109
|
+
|
|
110
|
+
The supplied [`ModelComposition`](../src/django_compose/model_composition.py) exposes
|
|
111
|
+
ordered models, donors, parents and contributed fields; see [model contracts](SPEC.md#model-declarations).
|
|
112
|
+
|
|
113
|
+
## Access verified output and readiness
|
|
114
|
+
|
|
115
|
+
| API | Purpose |
|
|
116
|
+
| --- | --- |
|
|
117
|
+
| `serving.artifact_path(relative)` | Return a receipt-owned generated artifact after checking its path and hash |
|
|
118
|
+
| `serving.verified_receipt()` | Read the process startup-verified `Receipt` |
|
|
119
|
+
| `serving.receipt_lease()` | Context manager holding shared output ownership while acting on that receipt |
|
|
120
|
+
| `provision.require_provisioned(using="default", timeout=0)` | Require database readiness for the verified build without repairing it |
|
|
121
|
+
|
|
122
|
+
See [artifact access](SPEC.md#artifact-access), [build records](SPEC.md#generated-output-and-freshness)
|
|
123
|
+
and [readiness](provisioning.md). Lower-level integrations can use
|
|
124
|
+
`serving.read_receipt(output_module)` (a path or module name) and
|
|
125
|
+
`serving.verify(snap, output_module, *, retain_startup=False)`;
|
|
126
|
+
project startup normally delegates verification to `configure`.
|
|
127
|
+
|
|
128
|
+
## Settings loaders and advanced integrations
|
|
129
|
+
|
|
130
|
+
- `conf.apply_app_settings(namespace, closure)` applies the same app contributions
|
|
131
|
+
to projects with [authored concrete models](configuration.md#app-settings-with-authored-models), without building output.
|
|
132
|
+
- Native yamlconf loaders use `conf.expand_attribute_refs(attributes)` and
|
|
133
|
+
`conf.fail_on_yamlconf_errors()` to preserve provenance and enforce native errors;
|
|
134
|
+
`conf.setting_name(key)` projects a native setting key's root. Follow the
|
|
135
|
+
[loader handoff](configuration.md#native-yamlconf-loader-handoff).
|
|
136
|
+
- [`snapshot.app_entries(entries)`](SPEC.md#application-selection) normalizes `Entry` identities;
|
|
137
|
+
[`snapshot.snapshot(entries, *, ...)`](SPEC.md#settings-and-snapshots) freezes `Snapshot` inputs for integrations;
|
|
138
|
+
ordinary projects use `configure` to keep input ordering in one place.
|
|
139
|
+
- `migrations.check_native_history(apps, *, labels)` compares effective native
|
|
140
|
+
state without database access; `migrations.history_labels()` reads retained
|
|
141
|
+
receipt labels. Projects author schema/data work through Django's native history.
|
|
142
|
+
- The optional `django_compose.typing` mypy plugin analyzes composed models through
|
|
143
|
+
django-stubs. See [installation, configuration and limitations](dependencies.md#advanced-typing).
|