django-compose 0.1.0.dev2__tar.gz → 0.1.0.dev3__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.dev2 → django_compose-0.1.0.dev3}/CHANGELOG.md +20 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/CONTRIBUTING.md +2 -1
- django_compose-0.1.0.dev3/PKG-INFO +98 -0
- django_compose-0.1.0.dev3/README.md +76 -0
- django_compose-0.1.0.dev3/docs/README.md +99 -0
- django_compose-0.1.0.dev3/docs/ROADMAP.md +17 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/SPEC.md +112 -65
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/components.md +38 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/configuration.md +60 -47
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/dependencies.md +19 -1
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/extensions.md +4 -1
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/migrations.md +30 -6
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/models.md +5 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/packaging.md +14 -5
- django_compose-0.1.0.dev3/docs/proposals/0001-native-url-collisions.md +25 -0
- django_compose-0.1.0.dev3/docs/proposals/0002-supplied-distribution-metadata.md +24 -0
- django_compose-0.1.0.dev3/docs/quickstart.md +95 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/pyproject.toml +1 -1
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/scripts/check_distribution.py +12 -3
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/artifacts.py +6 -6
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/build.py +1 -1
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/components.py +28 -11
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/migration_imports.py +5 -9
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/migrations.py +186 -24
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/model_composition.py +21 -12
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/typing.py +120 -10
- django_compose-0.1.0.dev3/src/django_compose/urls.py +79 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_artifacts.py +86 -1
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_bootstrap.py +45 -2
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_components.py +130 -2
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_history.py +43 -1
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_integrations.py +100 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_migrations_guards.py +333 -0
- django_compose-0.1.0.dev3/tests/test_migrations_postgres.py +198 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_provision_postgres.py +8 -3
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_typing.py +166 -0
- django_compose-0.1.0.dev3/tests/test_urls.py +285 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/uv.lock +1 -1
- django_compose-0.1.0.dev2/PKG-INFO +0 -111
- django_compose-0.1.0.dev2/README.md +0 -89
- django_compose-0.1.0.dev2/docs/README.md +0 -36
- django_compose-0.1.0.dev2/docs/ROADMAP.md +0 -28
- django_compose-0.1.0.dev2/docs/quickstart.md +0 -180
- django_compose-0.1.0.dev2/src/django_compose/urls.py +0 -58
- django_compose-0.1.0.dev2/tests/test_urls.py +0 -59
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/.gitignore +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/AGENTS.md +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/COPYING +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/LICENSE +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/Makefile +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/NOTICE +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/proposals/README.md +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/docs/provisioning.md +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/.gitignore +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/README.md +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/apps.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/autoconfig.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/integrations.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/management/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/management/commands/verify_context.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/models.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/pyproject.toml +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/schema.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/transport.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/catalog/urls.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/contexts.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/manage.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/reviews/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/reviews/apps.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/reviews/autoconfig.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/reviews/models.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/reviews/pyproject.toml +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/settings.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/urls.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/examples/shop/verify.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/__main__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/apps.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/asgi.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/autoreload.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/checks.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/cli.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/conf.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/declarations.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/history.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/check_migrations.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/compose.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/makemigrations.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/migrate.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/provision.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/reset_migration_history.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/management/commands/retire_history.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/models.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/provision.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/py.typed +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/rendering.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/serving.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/snapshot.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/src/django_compose/sources.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/core_fixtures/__init__.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_asgi.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_autoreload.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_boundaries.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_command_context.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_conf.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_initial_history.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_launcher.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_migration_imports.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_migration_scaffold.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_migrations.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_models.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_provision.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_snapshot.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_sources.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/test_startup.py +0 -0
- {django_compose-0.1.0.dev2 → django_compose-0.1.0.dev3}/tests/typing_fixtures/__init__.py +0 -0
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0.dev3
|
|
4
|
+
|
|
5
|
+
- Reorganize documentation around the project workflow, public APIs and app hooks,
|
|
6
|
+
with a shorter introduction and quick start.
|
|
7
|
+
- Expose `index_components(distributions, *, group)` for prepared native package
|
|
8
|
+
metadata; installed discovery delegates to the same validation and index.
|
|
9
|
+
- Protect quoted and schema-qualified migration storage, including implicit
|
|
10
|
+
many-to-many tables, using native eligibility and per-database ownership checks.
|
|
11
|
+
Keep reusable transition planning database-free.
|
|
12
|
+
- Reject integration literals that overwrite Django's generated parent links
|
|
13
|
+
before artifact hooks or ready callbacks run.
|
|
14
|
+
- Project effective extension member reads and calls through native MRO and
|
|
15
|
+
mypy member access while preserving authored-body and override diagnostics.
|
|
16
|
+
- Create new generated files with ordinary umask-filtered permissions while
|
|
17
|
+
preserving existing or explicit modes during atomic replacement.
|
|
18
|
+
- Diagnose identical native URL matching chains without rejecting disjoint
|
|
19
|
+
custom converters merely because they share a regex.
|
|
20
|
+
- Reuse packaging's distribution-name normalization and document Unix platform
|
|
21
|
+
requirements and the remaining property-setter typing limitation.
|
|
22
|
+
|
|
3
23
|
## 0.1.0.dev2
|
|
4
24
|
|
|
5
25
|
- Use component vocabulary for installed distributions, keeping distribution and
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
Use Python 3.14
|
|
3
|
+
Use Python 3.14 on a [supported platform](docs/dependencies.md#supported-platforms).
|
|
4
|
+
Read [AGENTS.md](AGENTS.md), the
|
|
4
5
|
[documentation index](docs/README.md), and the [specification](docs/SPEC.md) for the
|
|
5
6
|
area you change. This is an independent Django library: reproduce behavior in a
|
|
6
7
|
plain Django project, without requiring a downstream framework or live deployment.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: django-compose
|
|
3
|
+
Version: 0.1.0.dev3
|
|
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 resolves the apps selected by your project's `INSTALLED_APPS`,
|
|
28
|
+
combines their model declarations and settings contributions, and generates
|
|
29
|
+
ordinary Django models and app configurations before startup.
|
|
30
|
+
|
|
31
|
+
Use it when several projects share reusable apps but need different combinations
|
|
32
|
+
of fields and behavior. You author the project settings and launcher; Django
|
|
33
|
+
continues to own the app registry, ORM, managers, querysets and migrations.
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
installed apps + project settings → compose → generated Django package
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## What it provides
|
|
40
|
+
|
|
41
|
+
- **App selection:** expand explicit roots through declared app dependencies and
|
|
42
|
+
optional installed-package metadata.
|
|
43
|
+
- **Model composition:** add fields and methods to another app's model, create
|
|
44
|
+
concrete models, or declare native multi-table inheritance.
|
|
45
|
+
- **Project configuration:** combine app settings and optionally collect URL,
|
|
46
|
+
ASGI and database-preparation contributions.
|
|
47
|
+
- **Build output:** generate model/configuration modules and declared artifacts;
|
|
48
|
+
verify that they match the selected inputs before serving.
|
|
49
|
+
|
|
50
|
+
Packages remain installed at runtime because generated classes import their
|
|
51
|
+
source declarations. `compose` writes files; Django's migration commands change
|
|
52
|
+
the database.
|
|
53
|
+
|
|
54
|
+
## One model, two apps
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
# catalog/models.py
|
|
58
|
+
from django.db import models
|
|
59
|
+
from django_compose.models import Composable
|
|
60
|
+
|
|
61
|
+
class Item(Composable, concrete=True):
|
|
62
|
+
title = models.CharField(max_length=100)
|
|
63
|
+
|
|
64
|
+
class Meta:
|
|
65
|
+
abstract = True
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
# reviews/models.py
|
|
70
|
+
from django.db import models
|
|
71
|
+
from django_compose.models import Composable
|
|
72
|
+
|
|
73
|
+
class Rating(Composable, extends="catalog.Item"):
|
|
74
|
+
rating = models.PositiveSmallIntegerField(default=0)
|
|
75
|
+
|
|
76
|
+
class Meta:
|
|
77
|
+
abstract = True
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
With both apps selected, the generated `catalog.Item` has `title` and `rating` in
|
|
81
|
+
one table. `Rating` adds no table of its own. After composition, migrations and
|
|
82
|
+
Django setup, use `apps.get_model("catalog", "Item")` to obtain the concrete model.
|
|
83
|
+
The [model guide](https://github.com/ang-ee/django-compose/blob/main/docs/models.md)
|
|
84
|
+
explains all four declaration keywords and lazy relations.
|
|
85
|
+
|
|
86
|
+
## Get started
|
|
87
|
+
|
|
88
|
+
This is a development preview. See [compatibility and platform requirements](https://github.com/ang-ee/django-compose/blob/main/docs/dependencies.md)
|
|
89
|
+
and [installation](https://github.com/ang-ee/django-compose/blob/main/docs/packaging.md).
|
|
90
|
+
|
|
91
|
+
1. [Run the quick start](https://github.com/ang-ee/django-compose/blob/main/docs/quickstart.md)
|
|
92
|
+
to compose the checked-in SQLite project and query the result.
|
|
93
|
+
2. [Configure your project](https://github.com/ang-ee/django-compose/blob/main/docs/configuration.md)
|
|
94
|
+
with `configure(globals())` and the command launcher.
|
|
95
|
+
3. [Browse the APIs](https://github.com/ang-ee/django-compose/blob/main/docs/README.md)
|
|
96
|
+
for commands, Python entry points and app extension hooks.
|
|
97
|
+
|
|
98
|
+
Licensed under [LGPL-3.0-or-later](https://github.com/ang-ee/django-compose/blob/main/LICENSE).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# django-compose
|
|
2
|
+
|
|
3
|
+
Compose reusable Django apps into a runnable project.
|
|
4
|
+
|
|
5
|
+
django-compose resolves the apps selected by your project's `INSTALLED_APPS`,
|
|
6
|
+
combines their model declarations and settings contributions, and generates
|
|
7
|
+
ordinary Django models and app configurations before startup.
|
|
8
|
+
|
|
9
|
+
Use it when several projects share reusable apps but need different combinations
|
|
10
|
+
of fields and behavior. You author the project settings and launcher; Django
|
|
11
|
+
continues to own the app registry, ORM, managers, querysets and migrations.
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
installed apps + project settings → compose → generated Django package
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it provides
|
|
18
|
+
|
|
19
|
+
- **App selection:** expand explicit roots through declared app dependencies and
|
|
20
|
+
optional installed-package metadata.
|
|
21
|
+
- **Model composition:** add fields and methods to another app's model, create
|
|
22
|
+
concrete models, or declare native multi-table inheritance.
|
|
23
|
+
- **Project configuration:** combine app settings and optionally collect URL,
|
|
24
|
+
ASGI and database-preparation contributions.
|
|
25
|
+
- **Build output:** generate model/configuration modules and declared artifacts;
|
|
26
|
+
verify that they match the selected inputs before serving.
|
|
27
|
+
|
|
28
|
+
Packages remain installed at runtime because generated classes import their
|
|
29
|
+
source declarations. `compose` writes files; Django's migration commands change
|
|
30
|
+
the database.
|
|
31
|
+
|
|
32
|
+
## One model, two apps
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
# catalog/models.py
|
|
36
|
+
from django.db import models
|
|
37
|
+
from django_compose.models import Composable
|
|
38
|
+
|
|
39
|
+
class Item(Composable, concrete=True):
|
|
40
|
+
title = models.CharField(max_length=100)
|
|
41
|
+
|
|
42
|
+
class Meta:
|
|
43
|
+
abstract = True
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
# reviews/models.py
|
|
48
|
+
from django.db import models
|
|
49
|
+
from django_compose.models import Composable
|
|
50
|
+
|
|
51
|
+
class Rating(Composable, extends="catalog.Item"):
|
|
52
|
+
rating = models.PositiveSmallIntegerField(default=0)
|
|
53
|
+
|
|
54
|
+
class Meta:
|
|
55
|
+
abstract = True
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
With both apps selected, the generated `catalog.Item` has `title` and `rating` in
|
|
59
|
+
one table. `Rating` adds no table of its own. After composition, migrations and
|
|
60
|
+
Django setup, use `apps.get_model("catalog", "Item")` to obtain the concrete model.
|
|
61
|
+
The [model guide](https://github.com/ang-ee/django-compose/blob/main/docs/models.md)
|
|
62
|
+
explains all four declaration keywords and lazy relations.
|
|
63
|
+
|
|
64
|
+
## Get started
|
|
65
|
+
|
|
66
|
+
This is a development preview. See [compatibility and platform requirements](https://github.com/ang-ee/django-compose/blob/main/docs/dependencies.md)
|
|
67
|
+
and [installation](https://github.com/ang-ee/django-compose/blob/main/docs/packaging.md).
|
|
68
|
+
|
|
69
|
+
1. [Run the quick start](https://github.com/ang-ee/django-compose/blob/main/docs/quickstart.md)
|
|
70
|
+
to compose the checked-in SQLite project and query the result.
|
|
71
|
+
2. [Configure your project](https://github.com/ang-ee/django-compose/blob/main/docs/configuration.md)
|
|
72
|
+
with `configure(globals())` and the command launcher.
|
|
73
|
+
3. [Browse the APIs](https://github.com/ang-ee/django-compose/blob/main/docs/README.md)
|
|
74
|
+
for commands, Python entry points and app extension hooks.
|
|
75
|
+
|
|
76
|
+
Licensed under [LGPL-3.0-or-later](https://github.com/ang-ee/django-compose/blob/main/LICENSE).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# django-compose: usage and APIs
|
|
2
|
+
|
|
3
|
+
django-compose builds the generated part of a Django project from the reusable
|
|
4
|
+
apps you select. Apps contribute abstract model declarations, settings and
|
|
5
|
+
optional hooks; the result uses Django's ordinary registry, ORM and migrations.
|
|
6
|
+
|
|
7
|
+
Start with the [quick start](quickstart.md), then [configure your own project](configuration.md).
|
|
8
|
+
These docs follow this checkout. Use a [local installation](packaging.md#install-locally)
|
|
9
|
+
for changes marked **Unreleased** in the [changelog](../CHANGELOG.md).
|
|
10
|
+
|
|
11
|
+
## The workflow
|
|
12
|
+
|
|
13
|
+
1. Install the app packages and declare root apps in `INSTALLED_APPS`.
|
|
14
|
+
2. Call `configure(globals())` at the end of the project's settings.
|
|
15
|
+
3. Run `compose` to generate models, app configurations and declared artifacts.
|
|
16
|
+
4. Author and apply Django migrations, then run the project with that output.
|
|
17
|
+
|
|
18
|
+
Installing a package does not enable it. Source packages remain runtime
|
|
19
|
+
dependencies. Generated files can be rebuilt; migration files are durable
|
|
20
|
+
project history.
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
Use the [django-compose launcher](configuration.md#managepy) in `manage.py`.
|
|
25
|
+
|
|
26
|
+
| Command | Purpose | Guide |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `compose` | Generate output; `--check` verifies it and native history without writes; `--if-stale` skips generation when output is current | [Build lifecycle](SPEC.md#setup-lifecycle) |
|
|
29
|
+
| `makemigrations`, `migrate` | Author and apply ordinary Django migration history | [Migrations](migrations.md) |
|
|
30
|
+
| `runserver` | Recompose before Django's development-server reloads | [Development](configuration.md#serve-the-project) |
|
|
31
|
+
| `provision` | Apply migrations and optional app hooks; `--check` verifies readiness | [Provisioning](provisioning.md) |
|
|
32
|
+
| `check_migrations` | Compare model/history state; `--imports` audits retained Python dependencies | [History checks](migrations.md#disable-delete-or-uninstall) |
|
|
33
|
+
| `retire_history`, `reset_migration_history` | Perform explicit, guarded history maintenance | [Advanced migrations](migrations.md#advanced-destructive-changes-and-history-cutoffs) |
|
|
34
|
+
|
|
35
|
+
`django-compose inspect-apps [--group GROUP] APP_ENTRY ...` is a separate,
|
|
36
|
+
settings-free command. It prints the resolved selection as JSON; see
|
|
37
|
+
[inspection](components.md#inspect-a-selection-from-a-running-application).
|
|
38
|
+
|
|
39
|
+
## Python entry points
|
|
40
|
+
|
|
41
|
+
Import these from the indicated `django_compose` module. Detailed contracts,
|
|
42
|
+
validation and lifecycle rules live in the [API reference](SPEC.md).
|
|
43
|
+
|
|
44
|
+
| Module and API | Use it to |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `conf.configure(namespace)` | Configure a composed project, normally with `globals()` at the end of settings |
|
|
47
|
+
| `management.execute(argv=None)` | Dispatch management commands with composition selected before settings load |
|
|
48
|
+
| `models.Composable` | Declare abstract source models and extensions using the keywords below |
|
|
49
|
+
| `components.enabled_apps(roots, *, group=None)` | Resolve app dependencies into an immutable `Closure`; reads no project settings |
|
|
50
|
+
| `components.inspect_apps(roots, *, group=None, timeout=30.0)` | Resolve a selection in a fresh interpreter and return JSON-compatible `AppSelection` data |
|
|
51
|
+
| `components.installed_components(group)` | Index installed native package metadata without importing apps |
|
|
52
|
+
| `components.index_components(distributions, *, group)` | Apply the same indexing rules to supplied native `Distribution` objects |
|
|
53
|
+
| `components.active_requirements(requirements)` | Return native `Requirement` values active on this platform with `extra=""` |
|
|
54
|
+
| `conf.apply_app_settings(namespace, closure)` | Apply app settings to a project using ordinary authored concrete models |
|
|
55
|
+
| `provision.require_provisioned(using="default", timeout=0)` | Require recorded database readiness for the verified build |
|
|
56
|
+
| `serving.artifact_path(relative)` | Locate and verify a generated artifact |
|
|
57
|
+
| `serving.receipt_lease()` / `verified_receipt()` | Hold a shared build-record lease / read the startup-verified record |
|
|
58
|
+
|
|
59
|
+
Package indexing reads metadata; app selection imports native app/config modules.
|
|
60
|
+
Neither installs dependencies. See [components](components.md) for complete usage.
|
|
61
|
+
The optional [typing plugin](dependencies.md#advanced-typing) supplies composed-model
|
|
62
|
+
analysis through `django_compose.typing`.
|
|
63
|
+
|
|
64
|
+
## Model declaration keywords
|
|
65
|
+
|
|
66
|
+
Each declaration remains a Django abstract model: set `Meta.abstract = True`.
|
|
67
|
+
Targets use `app_label.Model` strings.
|
|
68
|
+
|
|
69
|
+
| Keyword | Generated result |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `concrete=True` | A concrete model with its own identity and table |
|
|
72
|
+
| `extends="catalog.Item"` | Fields and behavior contributed to that model; no separate table |
|
|
73
|
+
| `inherits="catalog.Item"` | A concrete child using Django multi-table inheritance; concrete is implied |
|
|
74
|
+
| `demands="catalog.Item"` | A constraint requiring every concrete descendant to have that ancestor |
|
|
75
|
+
|
|
76
|
+
`concrete`, `extends` and `inherits` are mutually exclusive. Only `demands`
|
|
77
|
+
propagates through abstract bases. See [model declarations](models.md) for examples.
|
|
78
|
+
|
|
79
|
+
## App extension hooks
|
|
80
|
+
|
|
81
|
+
| Declaration | Contribution | Guide |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `AppConfig.requires_apps` | Additional native app dependencies | [Selection](components.md#dependency-and-configuration-rules) |
|
|
84
|
+
| `autoconfig.py`: `SETTINGS`, `settings(namespace)` | Defaults and additive settings | [Configuration](configuration.md#app-settings-contributions) |
|
|
85
|
+
| `AppConfig.compose_urls` with optional prefix/namespace | Native URLconf contributions through `django_compose.urls` | [URLs](configuration.md#compose-app-urls) |
|
|
86
|
+
| `AppConfig.compose_asgi()` → `AsgiContribution` | HTTP mounts, protocols and lifespans through `django_compose.asgi.application` | [Serving](SPEC.md#serving-composition) |
|
|
87
|
+
| `AppConfig.compose_provision(context)` | Database preparation after migrations | [Provisioning](provisioning.md) |
|
|
88
|
+
| Classes in `COMPOSE_INTEGRATIONS` | Literal model metadata, generated artifacts or explicit migration-policy exemptions | [Integrations](extensions.md#supported-protocols) |
|
|
89
|
+
| `compose_migrations/` | Reusable native migration transitions | [Transitions](migrations.md#advanced-reusable-transitions) |
|
|
90
|
+
|
|
91
|
+
URL and ASGI composition require completed Django setup. Integrations implement
|
|
92
|
+
`ModelDeclarationHook`, `ArtifactHook` or `MigrationPolicy` from
|
|
93
|
+
`django_compose.declarations`; ordinary model behavior belongs in model bases.
|
|
94
|
+
|
|
95
|
+
## Reference and operations
|
|
96
|
+
|
|
97
|
+
[Detailed API contracts](SPEC.md) · [Deployment](packaging.md) ·
|
|
98
|
+
[Compatibility and typing](dependencies.md) · [Open work](ROADMAP.md) ·
|
|
99
|
+
[Contributing](../CONTRIBUTING.md)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Current scope and open work
|
|
2
|
+
|
|
3
|
+
The [API guide](README.md) describes what is available; the
|
|
4
|
+
[reference](SPEC.md) defines its contracts. Release changes belong in the
|
|
5
|
+
[changelog](../CHANGELOG.md).
|
|
6
|
+
|
|
7
|
+
Current boundaries and remaining verification:
|
|
8
|
+
|
|
9
|
+
- Component selection supports one Django app per participating distribution;
|
|
10
|
+
app-less and multi-app components are outside that contract. See [components](components.md).
|
|
11
|
+
- Python, Django, platform and typing support follow the [compatibility guide](dependencies.md),
|
|
12
|
+
including the known property-setter typing limitation.
|
|
13
|
+
- StatReloader edit, failure/recovery and file creation/deletion checks have run.
|
|
14
|
+
Watchman adapter tests cover the same declarations; acceptance against a native
|
|
15
|
+
Watchman daemon remains outstanding.
|
|
16
|
+
|
|
17
|
+
Changes to a public contract use the [proposal process](proposals/README.md).
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
# API reference
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[
|
|
1
|
+
# Detailed API reference
|
|
2
|
+
|
|
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 guide](README.md).
|
|
5
|
+
For runnable examples, use the [quick start](quickstart.md) and
|
|
6
|
+
[project configuration](configuration.md). [Compatibility](dependencies.md)
|
|
7
|
+
defines supported versions and platforms.
|
|
8
|
+
|
|
9
|
+
- [Terms](#terms)
|
|
10
|
+
- [Model declarations](#model-declarations)
|
|
11
|
+
- [Application selection](#application-selection)
|
|
12
|
+
- [Package metadata](#package-metadata)
|
|
13
|
+
- [Settings and snapshots](#settings-and-snapshots)
|
|
14
|
+
- [Setup lifecycle](#setup-lifecycle)
|
|
15
|
+
- [Integration protocols](#integration-protocols)
|
|
16
|
+
- [Generated output and freshness](#generated-output-and-freshness)
|
|
17
|
+
- [Artifact access](#artifact-access)
|
|
18
|
+
- [Native history and transitions](#native-history-and-transitions)
|
|
19
|
+
- [Database preparation and readiness](#database-preparation-and-readiness)
|
|
20
|
+
- [Serving composition](#serving-composition)
|
|
21
|
+
- [Typing and import boundaries](#typing-and-import-boundaries)
|
|
12
22
|
|
|
13
23
|
## Terms
|
|
14
24
|
|
|
@@ -17,8 +27,8 @@ to wire your own project. Planned APIs are described separately in
|
|
|
17
27
|
a selected source model; the composition-query API calls it a *donor*.
|
|
18
28
|
- A **generated model** is the concrete Django class emitted into the project's
|
|
19
29
|
generated package. Application code obtains it through Django's app registry.
|
|
20
|
-
- A **root app** is a project-authored `INSTALLED_APPS` entry. A **component** is
|
|
21
|
-
|
|
30
|
+
- A **root app** is a project-authored `INSTALLED_APPS` entry. A **component** is a
|
|
31
|
+
Python distribution participating in the optional selection group.
|
|
22
32
|
Each component currently provides one Django app. Distribution names, Python
|
|
23
33
|
import paths and native app identities remain distinct.
|
|
24
34
|
- A **snapshot** is the immutable set of composition inputs and their digest.
|
|
@@ -62,7 +72,9 @@ native method-resolution order. Shared abstract ancestry contributes once. The
|
|
|
62
72
|
first extension manager overrides a source manager; distinct extensions
|
|
63
73
|
claiming one manager name fail. Field-name, attname, same-table database-column,
|
|
64
74
|
field/manager and parent-field redeclaration collisions fail. Native generated
|
|
65
|
-
metadata also checks inherited and automatically created managers
|
|
75
|
+
metadata also checks inherited and automatically created managers and refuses
|
|
76
|
+
integration literals that replace structural fields, including implicit MTI
|
|
77
|
+
parent links and their attnames, before artifact hooks or ready callbacks.
|
|
66
78
|
Unknown targets,
|
|
67
79
|
parent or module dependency cycles, and unmet ancestor demands fail explicitly.
|
|
68
80
|
|
|
@@ -139,24 +151,24 @@ stdout. A reserved response descriptor carries only JSON; malformed or empty
|
|
|
139
151
|
responses raise `ImproperlyConfigured`. Selection failures exit with status 1.
|
|
140
152
|
This is a standalone command, not a Django management command.
|
|
141
153
|
|
|
142
|
-
##
|
|
143
|
-
|
|
144
|
-
`
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
`
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
## Package metadata
|
|
155
|
+
|
|
156
|
+
`components.index_components(distributions, *, group) -> InstalledComponents`
|
|
157
|
+
validates an iterable of native `importlib.metadata.Distribution` objects without
|
|
158
|
+
importing app modules or loading entry points. Prepared source metadata may use
|
|
159
|
+
native `Distribution.at(path)` / `PathDistribution`; preparation is caller-owned.
|
|
160
|
+
Each participating distribution declares exactly one group entry point. Duplicate
|
|
161
|
+
canonical distribution names and competing declared app keys fail explicitly.
|
|
162
|
+
Its read-only `distributions`, `entry_points` and `providers` maps retain native
|
|
163
|
+
objects, with canonical distribution-name and declared app-key indexes. Libraries
|
|
164
|
+
without group entries remain in `distributions`; indexing neither activates apps
|
|
165
|
+
nor checks importability, actual AppConfig identity or installed dependencies.
|
|
166
|
+
|
|
167
|
+
`components.installed_components(group)` selects each canonical installed name's
|
|
168
|
+
native `metadata.distribution()` winner, then delegates to that same index owner.
|
|
169
|
+
`active_requirements(iterable_of_strings)` and the index method
|
|
170
|
+
`active_requirements(provider)` return native Requirement values active with
|
|
171
|
+
`extra=""`. Metadata inspection does not activate apps.
|
|
160
172
|
|
|
161
173
|
## Settings and snapshots
|
|
162
174
|
|
|
@@ -409,7 +421,9 @@ A retry retains ownership of files written by an interrupted build.
|
|
|
409
421
|
A failed build remains `IN_PROGRESS`; reverting source bytes does not revive it.
|
|
410
422
|
Stale cleanup removes only previously recorded generated paths. Normal build
|
|
411
423
|
and clean preserve migration directories and unowned files, and refuse foreign
|
|
412
|
-
or symlinked trees.
|
|
424
|
+
or symlinked trees. Atomic publication uses the
|
|
425
|
+
[file-permission policy](packaging.md#prepare-the-application-artifact) for new
|
|
426
|
+
and existing files. First composition also admits a migration-only scaffold:
|
|
413
427
|
label directories containing native `migrations/` subtrees, with optional zero-byte
|
|
414
428
|
root/label `__init__.py` files. It preserves every history byte and file mode,
|
|
415
429
|
including disabled history graphs. Unknown files, symlinks and special files fail;
|
|
@@ -417,14 +431,22 @@ no foreign marker knowledge is required. This permits a fresh clone containing
|
|
|
417
431
|
only durable reviewed migration history to compose before serving. Check mode neither creates output nor changes
|
|
418
432
|
existing bytes. Preserve native history as explained in [packaging](packaging.md).
|
|
419
433
|
|
|
434
|
+
## Artifact access
|
|
435
|
+
|
|
436
|
+
`serving.verified_receipt()` returns the process startup receipt;
|
|
437
|
+
`serving.artifact_path(relative)` validates receipt ownership, safe
|
|
438
|
+
path and current hash before returning a Path. During build-ready callbacks it
|
|
439
|
+
supports models-phase artifacts before final publication.
|
|
440
|
+
|
|
420
441
|
## Native history and transitions
|
|
421
442
|
|
|
422
443
|
For generated labels, history defaults to `<output_module>.<label>.migrations`.
|
|
423
444
|
`serving.migration_modules(authored, receipt, output_module)` derives retained
|
|
424
445
|
defaults from the record, then applies authored overrides, including `None`.
|
|
425
446
|
`HISTORY_LABELS` retains model labels, previous history, on-disk migration
|
|
426
|
-
packages and transition targets, minus `RETIRED_LABELS`. History-only configs
|
|
427
|
-
|
|
447
|
+
packages and transition targets, minus `RETIRED_LABELS`. History-only configs use
|
|
448
|
+
`django_compose.history.History_<label>`, generated dynamically from retained
|
|
449
|
+
receipt facts; they load no old source models or app lifecycle.
|
|
428
450
|
|
|
429
451
|
Django owns migration detection, graphs, state, execution, recording and routers.
|
|
430
452
|
`effective_states(loader, registry, purge=...)` preserves history-only models in
|
|
@@ -456,9 +478,19 @@ historical adoption; new metadata uses `compose_origin` and
|
|
|
456
478
|
`compose_source_sha256`.
|
|
457
479
|
|
|
458
480
|
`DropGuardAutodetector`, shared by native `makemigrations` and `migrate`, requires
|
|
459
|
-
relevant rows or columns to be empty on every
|
|
460
|
-
destructive changes.
|
|
461
|
-
|
|
481
|
+
relevant rows or columns to be empty on every database eligible for the native
|
|
482
|
+
operation before automatic destructive changes. Eligibility includes native
|
|
483
|
+
model options and routers. Shared-table protection is per alias and includes
|
|
484
|
+
implicit many-to-many storage deleted with its owning model or field. Quoted identifiers
|
|
485
|
+
are resolved through backend semantics; unsupported or uncertain storage identity
|
|
486
|
+
and unavailable eligible databases cannot prove safety. Explicit integration-owned
|
|
487
|
+
row exemptions use `MigrationPolicy`. See the [storage proof's supported cases
|
|
488
|
+
and limits](migrations.md#advanced-destructive-changes-and-history-cutoffs).
|
|
489
|
+
|
|
490
|
+
Reusable transition planning remains database-free. It conservatively retains
|
|
491
|
+
feature-dependent aliases when checking the feature could connect, and refuses
|
|
492
|
+
ambiguous shared storage that requires database visibility to resolve. Explicit
|
|
493
|
+
migration authoring, purge and history maintenance use database-aware checks.
|
|
462
494
|
|
|
463
495
|
Retirement requires consistent fully applied history across all configured
|
|
464
496
|
migration-relevant aliases and refuses retained incoming cross-app dependencies.
|
|
@@ -482,27 +514,37 @@ no migration operations. `--imports --removing DIST...` refuses enabled provider
|
|
|
482
514
|
retained imports, unresolved/unsupported entries and loader failures; it does not
|
|
483
515
|
uninstall anything. See [migration workflows](migrations.md).
|
|
484
516
|
|
|
485
|
-
##
|
|
517
|
+
## Database preparation and readiness
|
|
486
518
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
fork versions; ordinary serving needs neither mypy nor django-stubs.
|
|
519
|
+
`django_compose.provision` owns database preparation for a startup-verified
|
|
520
|
+
composition. The native `provision` command is registered by the existing
|
|
521
|
+
ComposeConfig and supports `--database`, `--wait-db` and read-only `--check`.
|
|
522
|
+
Compose continues to generate artifacts without database work.
|
|
492
523
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
524
|
+
Optional `AppConfig.compose_provision(context)` hooks receive an immutable
|
|
525
|
+
`ProvisionContext(database, stdout, stderr, verbosity=1)` after native migrations.
|
|
526
|
+
The context's `call()` uses native management dispatch with the selected IO;
|
|
527
|
+
each hook supplies its command's supported database option. Apps without hooks
|
|
528
|
+
require no substitute. Resource declaration/loading policy stays with the
|
|
529
|
+
selected resource-owning app.
|
|
530
|
+
|
|
531
|
+
`require_provisioned(using="default", timeout=0)` verifies the current receipt
|
|
532
|
+
under its lease and reads readiness and native migration state without repair.
|
|
533
|
+
The single private recorder, durable failure/retry boundary, PostgreSQL lock and
|
|
534
|
+
explicit `base_provision` table cutover are defined in [provisioning](provisioning.md).
|
|
499
535
|
|
|
500
|
-
## Serving composition
|
|
536
|
+
## Serving composition
|
|
501
537
|
|
|
502
538
|
After `django.setup()`, `django_compose.urls.urlpatterns` includes selected
|
|
503
539
|
configs' optional `compose_urls` modules using `compose_url_prefix` (default empty)
|
|
504
|
-
and `compose_url_namespace` (default absent).
|
|
505
|
-
|
|
540
|
+
and `compose_url_namespace` (default absent). The registered native system check
|
|
541
|
+
reports identical native matching chains as `django_compose.E001`, naming both
|
|
542
|
+
contributing apps. Chains must have the same include boundaries, native matcher
|
|
543
|
+
types, compiled regex text and flags, endpoint behavior, capture names and
|
|
544
|
+
converter instances. Reverse namespaces do not distinguish matches. Different
|
|
545
|
+
converters, differently expressed chains and custom matching implementations
|
|
546
|
+
retain Django's ordered resolution; the check neither executes converters nor
|
|
547
|
+
proves arbitrary regex equivalence or overlap.
|
|
506
548
|
|
|
507
549
|
`django_compose.asgi.application` composes optional `config.compose_asgi()` factories
|
|
508
550
|
returning `AsgiContribution(http_mounts=..., lifespans=..., protocols=...)`.
|
|
@@ -512,19 +554,24 @@ Lifespan factories enter in app order, unwind in reverse and report startup/shut
|
|
|
512
554
|
failure. HTTP and lifespan are reserved protocols; duplicate mounts or protocol
|
|
513
555
|
claims fail. These modules require completed setup and install no server policy.
|
|
514
556
|
|
|
515
|
-
|
|
516
|
-
objects without importing app modules. Its read-only `distributions`, `entry_points`
|
|
517
|
-
and `providers` maps use canonical distribution names/app keys as documented by the
|
|
518
|
-
native owner. `active_requirements(iterable_of_strings)` and the index method
|
|
519
|
-
`active_requirements(provider)` return native Requirement values active with
|
|
520
|
-
`extra=""`. Metadata inspection does not activate apps.
|
|
557
|
+
## Typing and import boundaries
|
|
521
558
|
|
|
522
|
-
`
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
559
|
+
The optional `django_compose.typing` plugin extends django-stubs inference for
|
|
560
|
+
composed fields, relations, managers, methods, properties, generics and ancestor
|
|
561
|
+
demands, while retaining native diagnostics. Effective member access follows the
|
|
562
|
+
generated class's native MRO, including an extension overriding an existing source
|
|
563
|
+
member; authored bodies and override checks retain their original signatures.
|
|
564
|
+
The [typing guide](dependencies.md#advanced-typing) documents the remaining
|
|
565
|
+
read-only-to-writable property limitation. It tracks source dependencies for
|
|
566
|
+
cold, warm and incremental analysis. Its extra pins the supported published
|
|
567
|
+
fork versions; ordinary serving needs neither mypy nor django-stubs.
|
|
568
|
+
|
|
569
|
+
App selection, snapshots and serving are usable before Django setup when the
|
|
570
|
+
selected app/config modules satisfy Django's pre-setup import requirements.
|
|
571
|
+
Serving never imports the compiler; model declarations depend on native Django
|
|
572
|
+
models without importing build; build is loaded lazily by the build lifecycle.
|
|
573
|
+
Package imports do not configure Django or load a consumer framework. Django,
|
|
574
|
+
packaging and django-yamlconf are base dependencies; typing is optional.
|
|
528
575
|
|
|
529
576
|
`typing.CompositionPlugin.project_model` projects native generated model classes
|
|
530
577
|
into django-stubs TypeInfo in memory, including missing runtime-module symbols.
|
|
@@ -141,6 +141,44 @@ distribution names to selected app names. It reads no settings.
|
|
|
141
141
|
With no group it skips distribution discovery and follows only `requires_apps`;
|
|
142
142
|
an explicitly empty or invalid group fails. `configure` uses this same helper.
|
|
143
143
|
|
|
144
|
+
## Inspect package metadata without importing apps
|
|
145
|
+
|
|
146
|
+
`installed_components(group)` returns an `InstalledComponents` index of native
|
|
147
|
+
distribution and entry-point objects without importing apps or loading entry
|
|
148
|
+
points. To inspect metadata prepared separately by a package build backend, pass
|
|
149
|
+
native `Distribution` objects to the same indexing owner:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from importlib.metadata import Distribution
|
|
153
|
+
from pathlib import Path
|
|
154
|
+
|
|
155
|
+
from django_compose.components import index_components
|
|
156
|
+
|
|
157
|
+
metadata_dir = Path("build/metadata/shop_catalog-0.1.0.dist-info")
|
|
158
|
+
index = index_components(
|
|
159
|
+
[Distribution.at(metadata_dir)],
|
|
160
|
+
group="example.shop.apps",
|
|
161
|
+
)
|
|
162
|
+
print(index.providers) # {"shop_catalog": "shop-catalog"}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The metadata directory must already exist. Preparing it through the package's
|
|
166
|
+
build backend, obtaining source checkouts and installing dependencies belong to
|
|
167
|
+
the caller. Indexing needs neither an installed app nor an importable app package.
|
|
168
|
+
It does not enable apps or validate their AppConfig identity.
|
|
169
|
+
|
|
170
|
+
The read-only `distributions` map includes every supplied distribution, keyed by
|
|
171
|
+
canonical distribution name. `entry_points` maps participating distributions to
|
|
172
|
+
their native entry point; `providers` maps declared app keys to distribution names.
|
|
173
|
+
Participating distributions must have exactly one entry point in the requested
|
|
174
|
+
group, and app keys must be unique. Supplied canonical distribution names must
|
|
175
|
+
also be unique, even if their versions agree. Installed discovery uses Python's
|
|
176
|
+
native installed-distribution winner before delegating to this same validator.
|
|
177
|
+
|
|
178
|
+
`index.active_requirements(provider)` returns native `Requirement` objects active
|
|
179
|
+
with `extra=""`. Dependency presence and actual app identity are checked only when
|
|
180
|
+
apps are activated. Metadata in unrelated groups stays inactive.
|
|
181
|
+
|
|
144
182
|
## Inspect a selection from a running application
|
|
145
183
|
|
|
146
184
|
Use `inspect_apps` when an already populated application needs to inspect apps
|