django-compose 0.1.0.dev3__tar.gz → 0.1.0.dev5__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.
Files changed (113) hide show
  1. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/CHANGELOG.md +12 -0
  2. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/PKG-INFO +1 -1
  3. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/SPEC.md +8 -6
  4. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/dependencies.md +1 -1
  5. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/packaging.md +4 -4
  6. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/pyproject.toml +1 -1
  7. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/scripts/check_distribution.py +34 -10
  8. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/components.py +11 -3
  9. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/__init__.py +1 -1
  10. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/migrations.py +3 -0
  11. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/serving.py +1 -1
  12. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/snapshot.py +2 -2
  13. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/sources.py +20 -12
  14. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_components.py +71 -0
  15. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_launcher.py +24 -0
  16. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_migration_imports.py +20 -0
  17. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_migrations_guards.py +60 -0
  18. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_snapshot.py +50 -1
  19. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_sources.py +33 -3
  20. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/uv.lock +1 -1
  21. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/.gitignore +0 -0
  22. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/AGENTS.md +0 -0
  23. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/CONTRIBUTING.md +0 -0
  24. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/COPYING +0 -0
  25. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/LICENSE +0 -0
  26. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/Makefile +0 -0
  27. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/NOTICE +0 -0
  28. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/README.md +0 -0
  29. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/README.md +0 -0
  30. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/ROADMAP.md +0 -0
  31. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/components.md +0 -0
  32. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/configuration.md +0 -0
  33. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/extensions.md +0 -0
  34. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/migrations.md +0 -0
  35. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/models.md +0 -0
  36. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/proposals/0001-native-url-collisions.md +0 -0
  37. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/proposals/0002-supplied-distribution-metadata.md +0 -0
  38. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/proposals/README.md +0 -0
  39. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/provisioning.md +0 -0
  40. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/docs/quickstart.md +0 -0
  41. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/.gitignore +0 -0
  42. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/README.md +0 -0
  43. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/__init__.py +0 -0
  44. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/apps.py +0 -0
  45. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/autoconfig.py +0 -0
  46. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/integrations.py +0 -0
  47. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/management/__init__.py +0 -0
  48. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/management/commands/__init__.py +0 -0
  49. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/management/commands/verify_context.py +0 -0
  50. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/models.py +0 -0
  51. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/pyproject.toml +0 -0
  52. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/schema.py +0 -0
  53. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/transport.py +0 -0
  54. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/catalog/urls.py +0 -0
  55. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/contexts.py +0 -0
  56. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/manage.py +0 -0
  57. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/reviews/__init__.py +0 -0
  58. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/reviews/apps.py +0 -0
  59. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/reviews/autoconfig.py +0 -0
  60. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/reviews/models.py +0 -0
  61. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/reviews/pyproject.toml +0 -0
  62. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/settings.py +0 -0
  63. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/urls.py +0 -0
  64. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/examples/shop/verify.py +0 -0
  65. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/__init__.py +0 -0
  66. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/__main__.py +0 -0
  67. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/apps.py +0 -0
  68. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/artifacts.py +0 -0
  69. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/asgi.py +0 -0
  70. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/autoreload.py +0 -0
  71. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/build.py +0 -0
  72. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/checks.py +0 -0
  73. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/cli.py +0 -0
  74. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/conf.py +0 -0
  75. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/declarations.py +0 -0
  76. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/history.py +0 -0
  77. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/__init__.py +0 -0
  78. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/check_migrations.py +0 -0
  79. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/compose.py +0 -0
  80. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/makemigrations.py +0 -0
  81. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/migrate.py +0 -0
  82. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/provision.py +0 -0
  83. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/reset_migration_history.py +0 -0
  84. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/management/commands/retire_history.py +0 -0
  85. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/migration_imports.py +0 -0
  86. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/model_composition.py +0 -0
  87. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/models.py +0 -0
  88. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/provision.py +0 -0
  89. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/py.typed +0 -0
  90. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/rendering.py +0 -0
  91. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/typing.py +0 -0
  92. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/src/django_compose/urls.py +0 -0
  93. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/core_fixtures/__init__.py +0 -0
  94. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_artifacts.py +0 -0
  95. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_asgi.py +0 -0
  96. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_autoreload.py +0 -0
  97. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_bootstrap.py +0 -0
  98. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_boundaries.py +0 -0
  99. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_command_context.py +0 -0
  100. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_conf.py +0 -0
  101. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_history.py +0 -0
  102. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_initial_history.py +0 -0
  103. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_integrations.py +0 -0
  104. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_migration_scaffold.py +0 -0
  105. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_migrations.py +0 -0
  106. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_migrations_postgres.py +0 -0
  107. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_models.py +0 -0
  108. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_provision.py +0 -0
  109. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_provision_postgres.py +0 -0
  110. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_startup.py +0 -0
  111. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_typing.py +0 -0
  112. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/test_urls.py +0 -0
  113. {django_compose-0.1.0.dev3 → django_compose-0.1.0.dev5}/tests/typing_fixtures/__init__.py +0 -0
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0.dev5
4
+
5
+ - Respect Django's swapped-model storage semantics when guarding migrations, so
6
+ projects with a custom user model can create migrations and provision normally.
7
+
8
+ ## 0.1.0.dev4 — not published
9
+
10
+ The immutable tag is retained; these changes are included in dev5.
11
+
12
+ - Avoid distribution ownership scans for module-path lookups and reuse each exact
13
+ native app configuration within one dependency selection.
14
+
3
15
  ## 0.1.0.dev3
4
16
 
5
17
  - Reorganize documentation around the project workflow, public APIs and app hooks,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: django-compose
3
- Version: 0.1.0.dev3
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
@@ -106,6 +106,7 @@ root app names, and `required: frozenset[str]` of dependency-only app names.
106
106
  `components: Mapping[str, str]` maps selected canonical distribution names to
107
107
  their native app names. `dependencies` maps selected native app names to ordered
108
108
  direct dependency app names. These mappings are immutable.
109
+ Each exact app/config entry is resolved once per call; later calls resolve afresh.
109
110
 
110
111
  Each participating distribution declares exactly one group entry point, keyed
111
112
  by native `AppConfig.name`, whose value is a native app/config string. Active
@@ -275,12 +276,13 @@ the namespace. Deployment secrets are excluded unless deliberately named.
275
276
  Default exclusions can be replaced and prune the default Python walk. Explicit
276
277
  extra globs include matching files even beneath excluded directories. Other
277
278
  subdirectories, including any directory named `web`, are ordinary source inputs.
278
- One shared `SourceResolver` locates modules through native path finders over
279
- selected app directories and then `sys.path`, and determines installed providers
280
- through exact RECORD or PEP 610 ownership. Integration and transition module
281
- resolution does not execute their parent packages. Native app/config modules
282
- are imported to select configurations and must remain safe before Django setup.
283
- Snapshot and serving do not import the model compiler or execute integrations.
279
+ `SourceResolver` locates modules through native path finders over selected app
280
+ directories and then `sys.path`, without executing parent packages. Path-only
281
+ lookups for fingerprints, serving and reload inputs do not inspect distribution
282
+ metadata. Migration import audits additionally determine providers through exact
283
+ RECORD or PEP 610 ownership, with one lazy index per audit. Native app/config
284
+ modules are imported to select configurations and must remain safe before Django
285
+ setup. Snapshot and serving do not import the model compiler or execute integrations.
284
286
 
285
287
  Without `COMPOSE_TRANSITION_SOURCE`, each selected app contributes sorted
286
288
  `compose_migrations/<label>/<name>.py` files in app order, including numeric
@@ -50,7 +50,7 @@ The `typing` extra is unnecessary for building or running a project. Install it
50
50
  in the project's environment when you want composed-model analysis:
51
51
 
52
52
  ```sh
53
- python -m pip install 'django-compose[typing]==0.1.0.dev3'
53
+ python -m pip install 'django-compose[typing]==0.1.0.dev5'
54
54
  ```
55
55
 
56
56
  The extra installs published Angee forks of mypy and django-stubs, keeping their
@@ -1,6 +1,6 @@
1
1
  # Installation and deployment
2
2
 
3
- The current version is the development preview `0.1.0.dev3`, including component
3
+ The current version is the development preview `0.1.0.dev5`, including component
4
4
  selection, isolated inspection and native provisioning.
5
5
  Python 3.14 is the verified environment. The declared constraints are Python
6
6
  `>=3.14` and Django `>=6.1.2,<6.2`; see [dependencies](dependencies.md) and
@@ -9,10 +9,10 @@ Python 3.14 is the verified environment. The declared constraints are Python
9
9
  ## Install from PyPI
10
10
 
11
11
  ```sh
12
- python -m pip install django-compose==0.1.0.dev3
12
+ python -m pip install django-compose==0.1.0.dev5
13
13
  ```
14
14
 
15
- Use `django-compose[typing]==0.1.0.dev3` for the optional composition plugin and
15
+ Use `django-compose[typing]==0.1.0.dev5` for the optional composition plugin and
16
16
  its published typing dependencies; see [advanced typing](dependencies.md#advanced-typing).
17
17
 
18
18
  ## Install locally
@@ -36,7 +36,7 @@ environment:
36
36
  # In the django-compose checkout, with uv installed:
37
37
  uv build --wheel
38
38
  # In the project environment, using the actual archive path:
39
- python -m pip install /path/to/django-compose/dist/django_compose-0.1.0.dev3-py3-none-any.whl
39
+ python -m pip install /path/to/django-compose/dist/django_compose-0.1.0.dev5-py3-none-any.whl
40
40
  ```
41
41
 
42
42
  The base installation includes Django, packaging and django-yamlconf. Optional extras are described in
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "django-compose"
7
- version = "0.1.0.dev3"
7
+ version = "0.1.0.dev5"
8
8
  description = "Compose reusable Django apps into a runnable project."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14"
@@ -119,6 +119,12 @@ def installed_components(
119
119
  )
120
120
  host = directory / "installed-host"
121
121
  host.mkdir()
122
+ accounts = host / "accounts"
123
+ accounts.mkdir()
124
+ (accounts / "__init__.py").write_text("")
125
+ (accounts / "models.py").write_text(
126
+ "from django.contrib.auth.models import AbstractUser\nclass User(AbstractUser):\n pass\n"
127
+ )
122
128
  settings = """from pathlib import Path
123
129
  from django_compose.conf import configure
124
130
  BASE_DIR = Path(__file__).parent
@@ -127,20 +133,23 @@ DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DI
127
133
  DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
128
134
  COMPOSE_OUTPUT_DIR = BASE_DIR / "runtime"
129
135
  COMPOSE_OUTPUT_MODULE = "runtime"
130
- INSTALLED_APPS = ["catalog", "reviews"]
136
+ INSTALLED_APPS = [
137
+ "django.contrib.contenttypes", "django.contrib.auth", "accounts", "installed_reviews",
138
+ ]
139
+ AUTH_USER_MODEL = "accounts.User"
140
+ COMPOSE_COMPONENT_GROUP = "compose.smoke"
131
141
  configure(globals())
132
142
  """
133
- settings = settings.replace(
134
- 'INSTALLED_APPS = ["catalog", "reviews"]',
135
- 'INSTALLED_APPS = ["installed_reviews"]\nCOMPOSE_COMPONENT_GROUP = "compose.smoke"',
136
- )
137
143
  (host / "settings.py").write_text(settings)
138
144
  env = {**environment, "DJANGO_SETTINGS_MODULE": "settings"}
139
145
  compiler = [str(python), "-m", "django_compose"]
140
146
  run([*compiler, "compose"], cwd=host, env=env)
141
- run([*compiler, "makemigrations", "installed_catalog", "--noinput"], cwd=host, env=env)
142
- run([*compiler, "provision", "--wait-db", "0"], cwd=host, env=env)
143
- run([*compiler, "provision", "--check", "--wait-db", "0"], cwd=host, env=env)
147
+ run([*compiler, "makemigrations", "accounts", "installed_catalog", "--noinput"], cwd=host, env=env)
148
+ for _ in range(2):
149
+ run([*compiler, "provision", "--wait-db", "0"], cwd=host, env=env)
150
+ run([*compiler, "provision", "--check", "--wait-db", "0"], cwd=host, env=env)
151
+ result = run([*compiler, "migrate", "--noinput"], cwd=host, env=env)
152
+ assert "No migrations to apply" in result, result
144
153
  run([*compiler, "compose", "--check"], cwd=host, env=env)
145
154
  run(
146
155
  [
@@ -153,7 +162,11 @@ django.setup()
153
162
  from django.apps import apps
154
163
  from django.db.migrations.state import ProjectState
155
164
  from django.conf import settings
156
- assert settings.COMPOSE_ROOTS == ("installed_reviews",)
165
+ from django.contrib.auth import get_user_model
166
+ from django.db import connection
167
+ assert settings.COMPOSE_ROOTS == (
168
+ "django.contrib.contenttypes", "django.contrib.auth", "accounts", "installed_reviews",
169
+ )
157
170
  assert settings.COMPOSE_CLOSURE.components == {
158
171
  "compose-smoke-catalog": "installed_catalog", "compose-smoke-reviews": "installed_reviews",
159
172
  }
@@ -161,6 +174,7 @@ from django_compose.provision import require_provisioned
161
174
  require_provisioned()
162
175
  assert settings.SMOKE_CONTRIBUTORS == ["installed_catalog", "installed_reviews"]
163
176
  assert tuple(entry.name for entry in settings.COMPOSE_SNAPSHOT.entries) == (
177
+ "django.contrib.contenttypes", "django.contrib.auth", "accounts",
164
178
  "installed_catalog", "installed_reviews",
165
179
  )
166
180
  Item = apps.get_model("installed_catalog", "Item")
@@ -176,6 +190,16 @@ row = Child.objects.create(title="installed component", detail="child", rating=5
176
190
  assert Item.objects.get(pk=row.pk).rating == 5
177
191
  assert Child.objects.get(pk=row.pk).reviewed is True
178
192
  state = ProjectState.from_apps(apps)
193
+ swapped = state.apps.get_model("auth", "User")
194
+ assert swapped._meta.swapped == "accounts.User"
195
+ assert all(field.remote_field.through is None for field in swapped._meta.local_many_to_many)
196
+ User = get_user_model()
197
+ assert User._meta.label == "accounts.User"
198
+ assert "auth_user" not in connection.introspection.table_names()
199
+ user = User.objects.create_user(username="installed-user")
200
+ group = apps.get_model("auth", "Group").objects.create(name="installed-group")
201
+ user.groups.add(group)
202
+ assert user.groups.get() == group
179
203
  assert "installed_catalog.item" in state.models["installed_catalog", "child"].bases
180
204
  assert set(state.apps.get_model("installed_catalog", "Grandchild")._meta.parents) == {
181
205
  state.apps.get_model("installed_catalog", "Child"),
@@ -387,7 +411,7 @@ assert Item.objects.get(pk=item.pk).rating == 5
387
411
  print(
388
412
  "Wheel/sdist contents and fresh installed-host build, serve, ORM, "
389
413
  "migration, provisioning, drift, cleanup, installed component closure, "
390
- "MTI and import audit checks passed."
414
+ "custom-user provisioning, MTI and import audit checks passed."
391
415
  )
392
416
 
393
417
 
@@ -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
- root_configs = tuple((entry, AppConfig.create(entry)) for entry in root_entries)
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 = AppConfig.create(point.value)
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 = AppConfig.create(entry)
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(()).resolve(module)
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:
@@ -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
@@ -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().resolve(output_module)
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]
@@ -235,7 +235,7 @@ def _fingerprints(
235
235
  ) -> tuple[tuple[str, str], ...]:
236
236
  result = []
237
237
  for declaration in records:
238
- location = resolver.resolve(declaration["module"])
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.resolve(module)
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"}:
@@ -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 resolve(self, module: str) -> ModuleSource:
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 ModuleSource(
138
- module, path, "distribution" if names else "app" if app else "project", names, app, locations
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)
@@ -603,6 +603,77 @@ def test_closure_app_identities_reuse_selected_configs_without_reactivation(inst
603
603
  closure.app_entries = ()
604
604
 
605
605
 
606
+ @pytest.mark.parametrize("group", (None, GROUP))
607
+ def test_closure_resolves_shared_entries_once_and_keeps_native_configs_local(installed, monkeypatch, group):
608
+ shared = installed.app("selection_shared")
609
+ left = installed.app("selection_left", requires=(shared, shared))
610
+ right = installed.app("selection_right", requires=(shared,))
611
+ root = installed.app("selection_root", requires=(left, right, shared, shared))
612
+ requirements = {root: (left, right, shared), left: (shared,), right: (shared,), shared: ()}
613
+ for name, dependencies in requirements.items():
614
+ installed.distribution(name, app=name, requires=dependencies)
615
+ native_create = AppConfig.create
616
+ activations = []
617
+
618
+ def create(entry):
619
+ config = native_create(entry)
620
+ activations.append((entry, config))
621
+ return config
622
+
623
+ monkeypatch.setattr(AppConfig, "create", create)
624
+ first = enabled_apps((root,), group=group)
625
+ assert len(activations) == len(requirements)
626
+ assert sorted(entry for entry, _ in activations) == sorted(requirements)
627
+ first_configs = dict(activations)
628
+ assert all(config is first_configs[config.name] for config in first.app_configs)
629
+ assert first.entries == (shared, left, right, root)
630
+ activations.clear()
631
+
632
+ second = enabled_apps((root,), group=group)
633
+ assert first == second
634
+ assert len(activations) == len(requirements)
635
+ assert sorted(entry for entry, _ in activations) == sorted(requirements)
636
+ second_configs = dict(activations)
637
+ assert all(config is second_configs[config.name] for config in second.app_configs)
638
+ assert all(second_configs[name] is not first_configs[name] for name in requirements)
639
+
640
+
641
+ def test_closure_resolves_distinct_native_aliases_even_with_root_override(installed, monkeypatch):
642
+ target = installed.app(
643
+ "selection_target", configs="class SelectedConfig(DefaultConfig):\n default = False\n"
644
+ )
645
+ default = target + ".apps.DefaultConfig"
646
+ explicit = target + ".apps.SelectedConfig"
647
+ root = installed.app("selection_root", requires=(target, default, target, default))
648
+ installed.distribution("root-provider", app=root, requires=("target-provider",))
649
+ installed.distribution("target-provider", app=target)
650
+ native_create = AppConfig.create
651
+ activations = []
652
+
653
+ def create(entry):
654
+ activations.append(entry)
655
+ return native_create(entry)
656
+
657
+ monkeypatch.setattr(AppConfig, "create", create)
658
+ closure = enabled_apps((root, explicit), group=GROUP)
659
+ assert closure.entries == (explicit, root)
660
+ assert sorted(activations) == sorted((root, target, default, explicit))
661
+
662
+
663
+ def test_root_override_still_validates_native_dependency_config_collisions(installed):
664
+ target = installed.app(
665
+ "selection_target",
666
+ configs=(
667
+ " default = True\n"
668
+ "class OtherConfig(DefaultConfig):\n default = True\n"
669
+ "class SelectedConfig(DefaultConfig):\n default = False\n"
670
+ ),
671
+ )
672
+ root = installed.app("selection_root", requires=(target,))
673
+ with pytest.raises(RuntimeError, match="more than one default AppConfig"):
674
+ enabled_apps((root, target + ".apps.SelectedConfig"))
675
+
676
+
606
677
  def test_closure_configs_keep_dependency_order_and_tuple_immutability(installed):
607
678
  dependency = installed.app("native_owner_dependency")
608
679
  root = installed.app("native_owner_root", requires=(dependency,))
@@ -6,10 +6,14 @@ import json
6
6
  import os
7
7
  import subprocess
8
8
  import sys
9
+ from importlib import metadata
9
10
  from pathlib import Path
10
11
 
11
12
  import pytest
12
13
 
14
+ from django_compose.autoreload import InputReport
15
+ from django_compose.management import _fallback_inputs
16
+
13
17
 
14
18
  def invoke(
15
19
  root: Path, *arguments: str, env: dict[str, str] | None = None
@@ -150,6 +154,26 @@ def test_command_help_does_not_enter_context(tmp_path: Path) -> None:
150
154
  assert "first-enter" not in result.stdout
151
155
 
152
156
 
157
+ def test_fallback_settings_input_is_reported_without_import_or_distribution_metadata(tmp_path, monkeypatch):
158
+ package = tmp_path / "fallbackprobe"
159
+ package.mkdir()
160
+ (package / "__init__.py").write_text("raise AssertionError('parent executed')")
161
+ source = package / "settings.py"
162
+ source.write_text("raise AssertionError('settings executed')")
163
+ monkeypatch.syspath_prepend(str(tmp_path))
164
+ monkeypatch.setenv("DJANGO_SETTINGS_MODULE", "fallbackprobe.settings")
165
+ report = InputReport()
166
+ monkeypatch.setattr("django_compose.management.report_inputs", report.add)
167
+
168
+ def unexpected():
169
+ raise AssertionError("fallback reporting must not query distribution metadata")
170
+
171
+ monkeypatch.setattr(metadata, "distributions", unexpected)
172
+ _fallback_inputs()
173
+ assert report.files == {source}
174
+ assert not any(name.startswith("fallbackprobe") for name in sys.modules)
175
+
176
+
153
177
  def test_cold_failed_settings_report_retains_absent_candidates(tmp_path: Path) -> None:
154
178
  (tmp_path / "broken.py").write_text("""from django_compose.autoreload import report_inputs
155
179
  from pathlib import Path
@@ -10,6 +10,26 @@ from test_migrations import host as host
10
10
  from test_migrations import write
11
11
 
12
12
 
13
+ def test_one_lazy_distribution_index_per_native_migration_audit(host):
14
+ _, run = host
15
+ run("""
16
+ from importlib import metadata
17
+ from django_compose.migration_imports import MigrationImportReport
18
+ native = metadata.distributions
19
+ with patch.object(metadata, "distributions", wraps=native) as distributions:
20
+ report = MigrationImportReport()
21
+ assert distributions.call_count == 0
22
+ assert report.collect()
23
+ assert distributions.call_count == 1
24
+ assert report.removal_refusals(["Django"])
25
+ assert distributions.call_count == 1
26
+ another = MigrationImportReport()
27
+ assert distributions.call_count == 1
28
+ assert another.collect()
29
+ assert distributions.call_count == 2
30
+ """)
31
+
32
+
13
33
  def test_selected_authored_history_nested_helpers_dynamic_and_state_refs(host):
14
34
  root, run = host
15
35
  write(root, "helpers/__init__.py")
@@ -808,3 +808,63 @@ assert "shared_links" in connection.introspection.table_names()
808
808
  assert link._base_manager.get().pk == row.pk
809
809
  assert files() == original
810
810
  """)
811
+
812
+
813
+ @pytest.mark.parametrize("change", ["none", "swapped_model", "swapped_m2m", "active_m2m"])
814
+ def test_native_swapped_auth_storage_does_not_mask_active_through_protection(host, change):
815
+ root, run = host
816
+ write(root, "iam/__init__.py")
817
+ write(
818
+ root,
819
+ "iam/models.py",
820
+ """
821
+ from django.contrib.auth.models import AbstractUser
822
+ class User(AbstractUser):
823
+ pass
824
+ """,
825
+ )
826
+ run(f"""
827
+ from django.db.migrations.graph import MigrationGraph
828
+ from django.test import override_settings
829
+ with override_settings(
830
+ AUTH_USER_MODEL="iam.User",
831
+ INSTALLED_APPS=[commands, "django.contrib.contenttypes", "django.contrib.auth", "iam",
832
+ "alpha", "beta", "author"],
833
+ ):
834
+ before = ProjectState.from_apps(apps)
835
+ swapped = before.apps.get_model("auth", "User")
836
+ assert swapped._meta.swapped == "iam.User"
837
+ assert all(field.remote_field.through is None for field in swapped._meta.local_many_to_many)
838
+ assert not migrations.DeleteModel("User").allow_migrate_model("default", swapped)
839
+ graph = MigrationGraph()
840
+ for label in ("auth", "iam", "alpha", "beta", "contenttypes"):
841
+ graph.add_node((label, "0001"), migrations.Migration("0001", label))
842
+ if {change!r} == "active_m2m":
843
+ before.add_model(ModelState("beta", "Tag", [("id", models.AutoField(primary_key=True))]))
844
+ before.add_model(ModelState("beta", "Item", [
845
+ ("id", models.AutoField(primary_key=True)),
846
+ ("tags", models.ManyToManyField("beta.Tag", db_table='"active_links"')),
847
+ ]))
848
+ before.add_model(ModelState("beta", "Adopted", [("id", models.AutoField(primary_key=True))],
849
+ options={{"db_table": "active_links"}}))
850
+ with connection.schema_editor() as editor:
851
+ editor.create_model(before.apps.get_model("beta", "Tag"))
852
+ editor.create_model(before.apps.get_model("beta", "Item"))
853
+ after = before.clone()
854
+ if {change!r} == "swapped_model":
855
+ after.remove_model("auth", "user")
856
+ elif {change!r} == "swapped_m2m":
857
+ after.remove_field("auth", "user", "groups")
858
+ elif {change!r} == "active_m2m":
859
+ after.remove_field("beta", "item", "tags")
860
+ original = files()
861
+ action = lambda: DropGuardAutodetector(before, after).changes(graph)
862
+ if {change!r} == "active_m2m":
863
+ expect(CommandError, "still owned by beta.adopted", action)
864
+ assert before.apps.get_model("beta", "Adopted")._base_manager.count() == 0
865
+ else:
866
+ with patch.object(connection, "cursor", side_effect=AssertionError("swapped storage queried")):
867
+ changes = action()
868
+ assert bool(changes) is ({change!r} != "none")
869
+ assert files() == original
870
+ """)
@@ -5,12 +5,14 @@ import json
5
5
  import os
6
6
  import subprocess
7
7
  import sys
8
+ from importlib import metadata
8
9
 
9
10
  import pytest
10
11
  from django.core.exceptions import ImproperlyConfigured
11
12
 
13
+ from django_compose.autoreload import InputReport
12
14
  from django_compose.serving import Receipt, installed_apps, migration_modules, read_receipt, verify
13
- from django_compose.snapshot import Entry, snapshot, transition_declarations
15
+ from django_compose.snapshot import Entry, snapshot, transition_declarations, transition_fingerprints
14
16
 
15
17
 
16
18
  def test_snapshot_fingerprints_files_and_settings(tmp_path):
@@ -43,6 +45,10 @@ def test_snapshot_fingerprints_files_and_settings(tmp_path):
43
45
 
44
46
 
45
47
  def test_receipt_verify_checks_content_and_interruption(tmp_path, monkeypatch):
48
+ def unexpected():
49
+ raise AssertionError("receipt verification must not query distribution metadata")
50
+
51
+ monkeypatch.setattr(metadata, "distributions", unexpected)
46
52
  root = tmp_path / "generated"
47
53
  root.mkdir()
48
54
  (root / ".compose.lock").touch()
@@ -69,6 +75,49 @@ def test_receipt_verify_checks_content_and_interruption(tmp_path, monkeypatch):
69
75
  sys.modules.pop("generated", None)
70
76
 
71
77
 
78
+ def test_fingerprints_reread_and_report_inputs_without_distribution_metadata(tmp_path, monkeypatch):
79
+ app = tmp_path / "fingerprintprobe"
80
+ app.mkdir()
81
+ (app / "__init__.py").write_text("raise AssertionError('parent executed')")
82
+ integration = app / "hooks.py"
83
+ transition = app / "transition.py"
84
+ integration.write_text("first")
85
+ transition.write_text("first")
86
+ monkeypatch.syspath_prepend(str(tmp_path))
87
+ entries = (Entry("fingerprintprobe", "probe", "django.apps.AppConfig", str(app), "fingerprintprobe"),)
88
+ records = (
89
+ {"declaring_app": "fingerprintprobe", "name": "move", "app_label": "probe", "module": "transition"},
90
+ )
91
+
92
+ def unexpected():
93
+ raise AssertionError("fingerprinting must not query distribution metadata")
94
+
95
+ monkeypatch.setattr(metadata, "distributions", unexpected)
96
+
97
+ def capture():
98
+ report = InputReport()
99
+ monkeypatch.setattr("django_compose.autoreload.inputs", report)
100
+ result = snapshot(entries, integration_paths=("fingerprintprobe.hooks.Hook",), transitions=records)
101
+ assert {integration, transition} <= report.files
102
+ report.files.clear()
103
+ transitions = transition_fingerprints(records)
104
+ assert report.files == {transition}
105
+ return result, transitions
106
+
107
+ before, before_transitions = capture()
108
+ integration.write_text("other")
109
+ transition.write_text("other")
110
+ after, after_transitions = capture()
111
+ assert before.digest() != after.digest()
112
+ assert (
113
+ dict(before.files)["integration:fingerprintprobe.hooks"]
114
+ != dict(after.files)["integration:fingerprintprobe.hooks"]
115
+ )
116
+ assert before.transitions != after.transitions
117
+ assert before_transitions != after_transitions
118
+ assert "fingerprintprobe" not in sys.modules
119
+
120
+
72
121
  def test_settings_projection_keeps_authored_entries_and_none():
73
122
  entries = (
74
123
  Entry("app", "app", "app.apps.Config", "/app", "app.apps.Config"),
@@ -5,6 +5,8 @@ import sys
5
5
  from importlib import metadata
6
6
  from pathlib import Path
7
7
 
8
+ import pytest
9
+
8
10
  from django_compose.snapshot import Entry
9
11
  from django_compose.sources import SourceResolver, distribution_names, resolve_module
10
12
 
@@ -21,7 +23,8 @@ def distribution(root: Path, name: str, files=(), project: Path | None = None):
21
23
  return metadata.PathDistribution(info)
22
24
 
23
25
 
24
- def test_enabled_app_source_precedes_sys_path_without_importing_packages(tmp_path, monkeypatch):
26
+ @pytest.mark.parametrize("method", ["locate", "resolve"])
27
+ def test_enabled_app_source_precedes_sys_path_without_importing_packages(tmp_path, monkeypatch, method):
25
28
  wrong = tmp_path / "wrong" / "sourceprobe"
26
29
  right = tmp_path / "right" / "sourceprobe"
27
30
  for root, value in ((wrong, "wrong"), (right, "right")):
@@ -30,15 +33,42 @@ def test_enabled_app_source_precedes_sys_path_without_importing_packages(tmp_pat
30
33
  (root / "integrations" / "__init__.py").write_text("raise AssertionError('parent executed')")
31
34
  (root / "integrations" / "leaf.py").write_text(value)
32
35
  monkeypatch.syspath_prepend(str(wrong.parent))
33
- monkeypatch.setattr(metadata, "distributions", lambda: ())
36
+
37
+ def distributions():
38
+ assert method == "resolve", "location must not query distribution metadata"
39
+ return ()
40
+
41
+ monkeypatch.setattr(metadata, "distributions", distributions)
34
42
  entry = Entry("sourceprobe", "probe", "django.apps.AppConfig", str(right), "sourceprobe")
35
- source = resolve_module("sourceprobe.integrations.leaf", (entry,))
43
+ source = getattr(SourceResolver((entry,)), method)("sourceprobe.integrations.leaf")
36
44
  assert source.path == right / "integrations/leaf.py"
37
45
  assert source.kind == "app"
38
46
  assert source.app == "sourceprobe"
39
47
  assert not any(name.startswith("sourceprobe") for name in sys.modules)
40
48
 
41
49
 
50
+ def test_namespace_location_retains_all_portions_without_distribution_metadata(tmp_path, monkeypatch):
51
+ locations = tuple(tmp_path / name / "namespaceprobe" for name in ("first", "second"))
52
+ for location in locations:
53
+ location.mkdir(parents=True)
54
+ monkeypatch.syspath_prepend(str(location.parent))
55
+ leaf = locations[0] / "leaf.py"
56
+ leaf.write_text("raise AssertionError('must not execute')")
57
+
58
+ def unexpected():
59
+ raise AssertionError("location must not query distribution metadata")
60
+
61
+ monkeypatch.setattr(metadata, "distributions", unexpected)
62
+ resolver = SourceResolver()
63
+ namespace = resolver.locate("namespaceprobe")
64
+ assert namespace.path == locations[1]
65
+ assert namespace.search_locations == tuple(reversed(locations))
66
+ assert namespace.distributions == ()
67
+ assert namespace.kind == "project"
68
+ assert resolver.locate("namespaceprobe.leaf").path == leaf
69
+ assert "namespaceprobe" not in sys.modules
70
+
71
+
42
72
  def test_record_ownership_is_exact_for_shared_namespace(tmp_path, monkeypatch):
43
73
  package = tmp_path / "sharedprobe"
44
74
  package.mkdir()
@@ -348,7 +348,7 @@ wheels = [
348
348
 
349
349
  [[package]]
350
350
  name = "django-compose"
351
- version = "0.1.0.dev3"
351
+ version = "0.1.0.dev5"
352
352
  source = { editable = "." }
353
353
  dependencies = [
354
354
  { name = "django" },