django-compose 0.1.0.dev3__py3-none-any.whl → 0.1.0.dev5__py3-none-any.whl
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/components.py +11 -3
- django_compose/management/__init__.py +1 -1
- django_compose/migrations.py +3 -0
- django_compose/serving.py +1 -1
- django_compose/snapshot.py +2 -2
- django_compose/sources.py +20 -12
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/METADATA +1 -1
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/RECORD +13 -13
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/WHEEL +0 -0
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/entry_points.txt +0 -0
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/licenses/COPYING +0 -0
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/licenses/LICENSE +0 -0
- {django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/licenses/NOTICE +0 -0
django_compose/components.py
CHANGED
|
@@ -240,12 +240,20 @@ def enabled_apps(roots: Iterable[str], *, group: str | None = None) -> Closure:
|
|
|
240
240
|
|
|
241
241
|
Root configs are preselected and override dependency/default config choices.
|
|
242
242
|
Conflicting dependency configs, duplicate native labels and cycles fail.
|
|
243
|
+
Each exact app/config string resolves to one native instance per call.
|
|
243
244
|
"""
|
|
244
245
|
installed = installed_components(group) if group is not None else None
|
|
245
246
|
root_entries = tuple(roots)
|
|
246
247
|
if any(not isinstance(entry, str) for entry in root_entries):
|
|
247
248
|
raise ImproperlyConfigured("Root INSTALLED_APPS entries must be native app strings")
|
|
248
|
-
|
|
249
|
+
resolved: dict[str, AppConfig] = {}
|
|
250
|
+
|
|
251
|
+
def resolve(entry: str) -> AppConfig:
|
|
252
|
+
if entry not in resolved:
|
|
253
|
+
resolved[entry] = AppConfig.create(entry)
|
|
254
|
+
return resolved[entry]
|
|
255
|
+
|
|
256
|
+
root_configs = tuple((entry, resolve(entry)) for entry in root_entries)
|
|
249
257
|
normalized_roots = app_entries(Entry.from_config(config, entry) for entry, config in root_configs)
|
|
250
258
|
root_names = tuple(entry.name for entry in normalized_roots)
|
|
251
259
|
root_set = frozenset(root_names)
|
|
@@ -256,7 +264,7 @@ def enabled_apps(roots: Iterable[str], *, group: str | None = None) -> Closure:
|
|
|
256
264
|
def component_entry(provider: str) -> str:
|
|
257
265
|
assert installed is not None
|
|
258
266
|
point = installed.entry_points[provider]
|
|
259
|
-
config =
|
|
267
|
+
config = resolve(point.value)
|
|
260
268
|
if config.name != point.name:
|
|
261
269
|
raise ImproperlyConfigured(
|
|
262
270
|
f"Entry point {point.name!r} from {provider!r} selects app {config.name!r}"
|
|
@@ -264,7 +272,7 @@ def enabled_apps(roots: Iterable[str], *, group: str | None = None) -> Closure:
|
|
|
264
272
|
return point.value
|
|
265
273
|
|
|
266
274
|
def choose(entry: str) -> str:
|
|
267
|
-
config =
|
|
275
|
+
config = resolve(entry)
|
|
268
276
|
previous = selected.get(config.name)
|
|
269
277
|
if previous is None:
|
|
270
278
|
selected[config.name] = (entry, config)
|
|
@@ -100,7 +100,7 @@ def _fallback_inputs() -> None:
|
|
|
100
100
|
from django_compose.sources import SourceResolver
|
|
101
101
|
|
|
102
102
|
try:
|
|
103
|
-
location = SourceResolver(
|
|
103
|
+
location = SourceResolver().locate(module)
|
|
104
104
|
if location.path is not None:
|
|
105
105
|
report_inputs(files=[location.path])
|
|
106
106
|
except ImportError, ImproperlyConfigured, ValueError:
|
django_compose/migrations.py
CHANGED
|
@@ -563,6 +563,9 @@ def _allows_migrate_model(operation: Operation, alias: str, model: Any, *, offli
|
|
|
563
563
|
|
|
564
564
|
def _model_storage(model: Any, *, removed_field: str | None = None) -> Iterator[Any]:
|
|
565
565
|
"""Tables deleted by native model deletion or implicit M2M field removal."""
|
|
566
|
+
# Django intentionally creates no implicit through classes for swapped models.
|
|
567
|
+
if model._meta.swapped:
|
|
568
|
+
return
|
|
566
569
|
if removed_field is None:
|
|
567
570
|
yield model
|
|
568
571
|
fields = model._meta.local_many_to_many
|
django_compose/serving.py
CHANGED
|
@@ -186,7 +186,7 @@ def read_receipt(output_module: Path | str) -> Receipt | None:
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
def output_directory(output_module: str) -> Path:
|
|
189
|
-
source = SourceResolver().
|
|
189
|
+
source = SourceResolver().locate(output_module)
|
|
190
190
|
if len(source.search_locations) != 1:
|
|
191
191
|
raise ImproperlyConfigured(f"Missing generated package {output_module!r}; run compose")
|
|
192
192
|
root = source.search_locations[0]
|
django_compose/snapshot.py
CHANGED
|
@@ -235,7 +235,7 @@ def _fingerprints(
|
|
|
235
235
|
) -> tuple[tuple[str, str], ...]:
|
|
236
236
|
result = []
|
|
237
237
|
for declaration in records:
|
|
238
|
-
location = resolver.
|
|
238
|
+
location = resolver.locate(declaration["module"])
|
|
239
239
|
if location.path is not None:
|
|
240
240
|
report_inputs(files=[location.path])
|
|
241
241
|
if location.path is None or not location.path.is_file():
|
|
@@ -388,7 +388,7 @@ def snapshot(
|
|
|
388
388
|
if owner is not object:
|
|
389
389
|
modules[f"config:{owner.__module__}"] = owner.__module__
|
|
390
390
|
for key, module in sorted(modules.items()):
|
|
391
|
-
location = resolver.
|
|
391
|
+
location = resolver.locate(module)
|
|
392
392
|
if location.path is not None:
|
|
393
393
|
report_inputs(files=[location.path])
|
|
394
394
|
if location.kind in {"builtin", "frozen"}:
|
django_compose/sources.py
CHANGED
|
@@ -6,7 +6,7 @@ import json
|
|
|
6
6
|
import sys
|
|
7
7
|
import sysconfig
|
|
8
8
|
from collections.abc import Iterable
|
|
9
|
-
from dataclasses import dataclass
|
|
9
|
+
from dataclasses import dataclass, replace
|
|
10
10
|
from importlib import metadata
|
|
11
11
|
from importlib.machinery import BuiltinImporter, FrozenImporter, ModuleSpec, PathFinder
|
|
12
12
|
from pathlib import Path
|
|
@@ -93,12 +93,12 @@ class SourceResolver:
|
|
|
93
93
|
search = list(spec.submodule_search_locations)
|
|
94
94
|
return None
|
|
95
95
|
|
|
96
|
-
def
|
|
96
|
+
def _locate(self, module: str) -> tuple[ModuleSource, tuple[Path, ...]]:
|
|
97
97
|
if not module or not all(part and ("_" + part).isidentifier() for part in module.split(".")):
|
|
98
|
-
return ModuleSource(module, None, "unresolved")
|
|
98
|
+
return ModuleSource(module, None, "unresolved"), ()
|
|
99
99
|
for finder, kind in ((BuiltinImporter, "builtin"), (FrozenImporter, "frozen")):
|
|
100
100
|
if finder.find_spec(module) is not None:
|
|
101
|
-
return ModuleSource(module, None, kind)
|
|
101
|
+
return ModuleSource(module, None, kind), ()
|
|
102
102
|
spec = None
|
|
103
103
|
for entry in self.entries:
|
|
104
104
|
if module == entry.name:
|
|
@@ -114,11 +114,11 @@ class SourceResolver:
|
|
|
114
114
|
if spec is None:
|
|
115
115
|
spec = self._find(module.split("."))
|
|
116
116
|
if spec is None:
|
|
117
|
-
return ModuleSource(module, None, "unresolved")
|
|
117
|
+
return ModuleSource(module, None, "unresolved"), ()
|
|
118
118
|
locations = tuple(Path(path).resolve() for path in spec.submodule_search_locations or ())
|
|
119
119
|
path = Path(spec.origin).resolve() if spec.origin else next(iter(locations), None)
|
|
120
120
|
if path is None:
|
|
121
|
-
return ModuleSource(module, None, "unresolved")
|
|
121
|
+
return ModuleSource(module, None, "unresolved"), ()
|
|
122
122
|
paths = sysconfig.get_paths()
|
|
123
123
|
site_roots = {Path(paths[key]).resolve() for key in ("purelib", "platlib")}
|
|
124
124
|
if (
|
|
@@ -126,18 +126,26 @@ class SourceResolver:
|
|
|
126
126
|
and path.is_relative_to(Path(paths["stdlib"]).resolve())
|
|
127
127
|
and not any(path.is_relative_to(root) for root in site_roots)
|
|
128
128
|
):
|
|
129
|
-
return ModuleSource(module, path, "stdlib")
|
|
129
|
+
return ModuleSource(module, path, "stdlib"), ()
|
|
130
130
|
ownership_paths = (path,) if spec.origin else locations
|
|
131
|
-
names = tuple(
|
|
132
|
-
sorted({name for source in ownership_paths for name in self.distribution_names(source)})
|
|
133
|
-
)
|
|
134
131
|
app = next(
|
|
135
132
|
(entry.name for entry in self.entries if path.is_relative_to(Path(entry.path).resolve())), None
|
|
136
133
|
)
|
|
137
|
-
return
|
|
138
|
-
module, path, "
|
|
134
|
+
return (
|
|
135
|
+
ModuleSource(module, path, "app" if app else "project", app=app, search_locations=locations),
|
|
136
|
+
ownership_paths,
|
|
139
137
|
)
|
|
140
138
|
|
|
139
|
+
def locate(self, module: str) -> ModuleSource:
|
|
140
|
+
"""Locate without imports or distribution metadata; kind excludes installed ownership."""
|
|
141
|
+
return self._locate(module)[0]
|
|
142
|
+
|
|
143
|
+
def resolve(self, module: str) -> ModuleSource:
|
|
144
|
+
"""Locate and attribute exact installed ownership, indexing metadata once per resolver."""
|
|
145
|
+
source, ownership_paths = self._locate(module)
|
|
146
|
+
names = tuple(sorted({name for path in ownership_paths for name in self.distribution_names(path)}))
|
|
147
|
+
return replace(source, kind="distribution", distributions=names) if names else source
|
|
148
|
+
|
|
141
149
|
|
|
142
150
|
def resolve_module(module: str, entries: Iterable[AppSource] = ()) -> ModuleSource:
|
|
143
151
|
return SourceResolver(entries).resolve(module)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-compose
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev5
|
|
4
4
|
Summary: Compose reusable Django apps into a runnable project.
|
|
5
5
|
Project-URL: Source, https://github.com/ang-ee/django-compose
|
|
6
6
|
Project-URL: Documentation, https://github.com/ang-ee/django-compose/tree/main/docs
|
|
@@ -7,23 +7,23 @@ django_compose/autoreload.py,sha256=Obguzio30T42nIjSX9HVmrU-CqtTrm7moU0Wd271Egg,
|
|
|
7
7
|
django_compose/build.py,sha256=hxLad46ZIU5QdD0f6e6TUtk3W9XQEXXgHyZQXeMhfFU,11766
|
|
8
8
|
django_compose/checks.py,sha256=68mO4E6_UPYhya9wjO-SsQ2YFnDSl0q_fI8r-DnSTZ0,366
|
|
9
9
|
django_compose/cli.py,sha256=9YlvZY7-qPVtuTXpMA5KxtAZd-TzTVCrg-2F4cNodUM,1209
|
|
10
|
-
django_compose/components.py,sha256=
|
|
10
|
+
django_compose/components.py,sha256=jNMkWm0Q15dbmVkK3jBdM_ldgqilFitvrfGaRHxmXx0,14518
|
|
11
11
|
django_compose/conf.py,sha256=Y6wEhxZh2gT_XjooEjc_5Ry0MOEIaPH4yCOf6UlZo-U,15838
|
|
12
12
|
django_compose/declarations.py,sha256=JJ09haPmgua4h2P9T8-fMos3CWHdQMpWkw15gXlL1nM,6900
|
|
13
13
|
django_compose/history.py,sha256=-D9jT-2EvKH6HDo3EfDeTD6lxUirgQOxeDh4cJKLoAU,1291
|
|
14
14
|
django_compose/migration_imports.py,sha256=vyg8NdUCl977HrdfBkz642x0ra_btaRdCqZEfQs4V2o,22011
|
|
15
|
-
django_compose/migrations.py,sha256=
|
|
15
|
+
django_compose/migrations.py,sha256=oHkVHiYk-iq64cDio6zDSBNMEFwZax2Cfk8UommYzxw,49469
|
|
16
16
|
django_compose/model_composition.py,sha256=470nEltv-x6JYl_AWaQxK6cUOnOQe7e63y-Ehi_WrnM,16547
|
|
17
17
|
django_compose/models.py,sha256=hM0ed-sotXh2vdI0zNESYnX_qS_39_IHwAk4jZnpYXU,2512
|
|
18
18
|
django_compose/provision.py,sha256=ufGuc1jesX6gid-s1a-rNwQbKvKcgnOjvSPwVdUrHF4,15321
|
|
19
19
|
django_compose/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
django_compose/rendering.py,sha256=1OFZU7lLMO2rD4S9K1-g8wvdn8RKBnUuQTFPHnDWsHY,3647
|
|
21
|
-
django_compose/serving.py,sha256=
|
|
22
|
-
django_compose/snapshot.py,sha256=
|
|
23
|
-
django_compose/sources.py,sha256=
|
|
21
|
+
django_compose/serving.py,sha256=FoS3TNNpgPGLpfCHtGrW0JVJVT9DyI7sxJ5U4x0oVLU,15498
|
|
22
|
+
django_compose/snapshot.py,sha256=115gi4SRkYUu2JFf_GC8kORPUWGy9z0BGlTyhNZxZYg,17730
|
|
23
|
+
django_compose/sources.py,sha256=fLBGSHtAInnoTM1Z2Wdt74P_cbLUUP4MWD1l2uS_zAI,6629
|
|
24
24
|
django_compose/typing.py,sha256=13pd3JfIoBV8v4AHK-QgAg9J8C4Miz_D0dmHFEwUG4I,36089
|
|
25
25
|
django_compose/urls.py,sha256=PZLa-pGe5JgzpUgu9sOEUbO2FgLGPkZZSOhRD1ZLgUk,2969
|
|
26
|
-
django_compose/management/__init__.py,sha256=
|
|
26
|
+
django_compose/management/__init__.py,sha256=wBX58M8MHUEvl9M57wVNNDAq4lsCSLjPtM3Copabs2w,8724
|
|
27
27
|
django_compose/management/commands/__init__.py,sha256=_mgOwmIp5-GhgJd6tY4Wc89G0EJDiHF9tYo8F63ytm8,40
|
|
28
28
|
django_compose/management/commands/check_migrations.py,sha256=CIGGQCq-01Cm0_ZR7Exl4EtM_-qnFfhzfMsLxhl8P5A,2918
|
|
29
29
|
django_compose/management/commands/compose.py,sha256=UuNjIgNwYOYE_1aKIcEvh3C1fMjP9tdN_-SDDwVQjIc,1860
|
|
@@ -32,10 +32,10 @@ django_compose/management/commands/migrate.py,sha256=_MkiQRjQRwIr9dEUnKk4WEjLgz5
|
|
|
32
32
|
django_compose/management/commands/provision.py,sha256=4GTPwH1Pp1V_YkztDZxeHuyAjDUHjZxhkdvFlrgDBfU,1035
|
|
33
33
|
django_compose/management/commands/reset_migration_history.py,sha256=PD3baeH1jQHIXXLaEYyxZXfhVYfJLzTXnv-XF1ySULQ,1489
|
|
34
34
|
django_compose/management/commands/retire_history.py,sha256=3RV1-w5Niij0svr0gB_gAjBgskxCYtdg5pPfsGN287s,886
|
|
35
|
-
django_compose-0.1.0.
|
|
36
|
-
django_compose-0.1.0.
|
|
37
|
-
django_compose-0.1.0.
|
|
38
|
-
django_compose-0.1.0.
|
|
39
|
-
django_compose-0.1.0.
|
|
40
|
-
django_compose-0.1.0.
|
|
41
|
-
django_compose-0.1.0.
|
|
35
|
+
django_compose-0.1.0.dev5.dist-info/METADATA,sha256=Pc9V5woPKK6K8UEae8GhJ-jq7rcjA8aGAurtGFfCvzM,3939
|
|
36
|
+
django_compose-0.1.0.dev5.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
37
|
+
django_compose-0.1.0.dev5.dist-info/entry_points.txt,sha256=-Iw1c8YAegCC53YCKgPXjIZn4aPS3MmEKbcMrCpUMFU,59
|
|
38
|
+
django_compose-0.1.0.dev5.dist-info/licenses/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
39
|
+
django_compose-0.1.0.dev5.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
40
|
+
django_compose-0.1.0.dev5.dist-info/licenses/NOTICE,sha256=C4fEGI9_-a1GCPfAH9bC0ZvmZFS71b9Z4v6rjrT5dxA,450
|
|
41
|
+
django_compose-0.1.0.dev5.dist-info/RECORD,,
|
|
File without changes
|
{django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|
{django_compose-0.1.0.dev3.dist-info → django_compose-0.1.0.dev5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|