django-compose 0.1.0.dev9__py3-none-any.whl → 0.1.0.dev10__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/sources.py +41 -32
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/METADATA +1 -1
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/RECORD +8 -8
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/WHEEL +0 -0
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/entry_points.txt +0 -0
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/licenses/COPYING +0 -0
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/licenses/LICENSE +0 -0
- {django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/licenses/NOTICE +0 -0
django_compose/sources.py
CHANGED
|
@@ -9,6 +9,7 @@ from collections.abc import Iterable
|
|
|
9
9
|
from dataclasses import dataclass, replace
|
|
10
10
|
from importlib import metadata
|
|
11
11
|
from importlib.machinery import BuiltinImporter, FrozenImporter, ModuleSpec, PathFinder
|
|
12
|
+
from itertools import chain
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
from typing import Protocol
|
|
14
15
|
from urllib.parse import unquote, urlsplit
|
|
@@ -42,41 +43,49 @@ class SourceResolver:
|
|
|
42
43
|
distributions: Iterable[metadata.Distribution] | None = None,
|
|
43
44
|
) -> None:
|
|
44
45
|
self.entries = tuple(sorted(entries, key=lambda entry: -len(entry.name)))
|
|
45
|
-
|
|
46
|
-
self.
|
|
47
|
-
self.
|
|
46
|
+
# A one-shot iterable is held whole so a failed index build fails again on retry.
|
|
47
|
+
self._distributions = None if distributions is None else tuple(distributions)
|
|
48
|
+
self._owners: dict[Path, set[str]] | None = None
|
|
49
|
+
|
|
50
|
+
def _index(self) -> tuple[dict[Path, set[str]], dict[Path, set[str]]]:
|
|
51
|
+
"""Key each resolved RECORD file and its ancestors, and each PEP 610 project, to owners."""
|
|
52
|
+
owners: dict[Path, set[str]] = {}
|
|
53
|
+
projects: dict[Path, set[str]] = {}
|
|
54
|
+
distributions = self._distributions
|
|
55
|
+
for distribution in metadata.distributions() if distributions is None else distributions:
|
|
56
|
+
name = distribution.metadata["Name"]
|
|
57
|
+
if not name:
|
|
58
|
+
continue
|
|
59
|
+
for file in distribution.files or ():
|
|
60
|
+
location = Path(str(distribution.locate_file(file))).resolve()
|
|
61
|
+
for directory in chain((location,), location.parents):
|
|
62
|
+
names = owners.setdefault(directory, set())
|
|
63
|
+
if name in names:
|
|
64
|
+
break # Every further ancestor already records this distribution.
|
|
65
|
+
names.add(name)
|
|
66
|
+
direct = distribution.read_text("direct_url.json")
|
|
67
|
+
if direct:
|
|
68
|
+
try:
|
|
69
|
+
direct_url = json.loads(direct)
|
|
70
|
+
url = urlsplit(direct_url.get("url", ""))
|
|
71
|
+
if "dir_info" in direct_url and url.scheme == "file" and url.netloc in ("", "localhost"):
|
|
72
|
+
projects.setdefault(Path(unquote(url.path)).resolve(), set()).add(name)
|
|
73
|
+
except ValueError, TypeError, AttributeError:
|
|
74
|
+
continue
|
|
75
|
+
return owners, projects
|
|
48
76
|
|
|
49
77
|
def distribution_names(self, path: Path) -> tuple[str, ...]:
|
|
50
|
-
"""Match RECORD files or a PEP 610 local project directory, never package names.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
continue
|
|
58
|
-
for file in distribution.files or ():
|
|
59
|
-
location = Path(str(distribution.locate_file(file))).resolve()
|
|
60
|
-
self._files.setdefault(location, set()).add(name)
|
|
61
|
-
direct = distribution.read_text("direct_url.json")
|
|
62
|
-
if direct:
|
|
63
|
-
try:
|
|
64
|
-
record = json.loads(direct)
|
|
65
|
-
url = urlsplit(record.get("url", ""))
|
|
66
|
-
if "dir_info" in record and url.scheme == "file" and url.netloc in ("", "localhost"):
|
|
67
|
-
self._projects.append((Path(unquote(url.path)).resolve(), name))
|
|
68
|
-
except ValueError, TypeError, AttributeError:
|
|
69
|
-
continue
|
|
78
|
+
"""Match RECORD files or a PEP 610 local project directory, never package names.
|
|
79
|
+
|
|
80
|
+
A path is owned by every distribution recording a file at or beneath it. Lookups
|
|
81
|
+
read the once-built index by key, so their cost never grows with recorded files.
|
|
82
|
+
"""
|
|
83
|
+
if self._owners is None:
|
|
84
|
+
self._owners, self._projects = self._index()
|
|
70
85
|
location = path.resolve()
|
|
71
|
-
names = self.
|
|
72
|
-
|
|
73
|
-
names.update(
|
|
74
|
-
name
|
|
75
|
-
for file, owners in self._files.items()
|
|
76
|
-
if file.is_relative_to(location)
|
|
77
|
-
for name in owners
|
|
78
|
-
)
|
|
79
|
-
names.update(name for root, name in self._projects if location.is_relative_to(root))
|
|
86
|
+
names = set(self._owners.get(location, ()))
|
|
87
|
+
for directory in chain((location,), location.parents):
|
|
88
|
+
names.update(self._projects.get(directory, ()))
|
|
80
89
|
return tuple(sorted(names))
|
|
81
90
|
|
|
82
91
|
@staticmethod
|
|
@@ -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.dev10
|
|
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
|
|
@@ -18,7 +18,7 @@ django_compose/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
18
18
|
django_compose/rendering.py,sha256=1OFZU7lLMO2rD4S9K1-g8wvdn8RKBnUuQTFPHnDWsHY,3647
|
|
19
19
|
django_compose/serving.py,sha256=FoS3TNNpgPGLpfCHtGrW0JVJVT9DyI7sxJ5U4x0oVLU,15498
|
|
20
20
|
django_compose/snapshot.py,sha256=pHVV9P-gDM_JukVxav3veICgDYc_8xm4RFLdr0mvM00,13554
|
|
21
|
-
django_compose/sources.py,sha256=
|
|
21
|
+
django_compose/sources.py,sha256=lT3BMOUK2BwVsLj-esb6ItCR60AsvbMTq6Otcm7NVuA,7229
|
|
22
22
|
django_compose/typing.py,sha256=13pd3JfIoBV8v4AHK-QgAg9J8C4Miz_D0dmHFEwUG4I,36089
|
|
23
23
|
django_compose/management/__init__.py,sha256=z5LGwZCxfGd44kJWDpQZkdwclHwfFlBgCBfJjPmcdI0,7156
|
|
24
24
|
django_compose/management/commands/__init__.py,sha256=_mgOwmIp5-GhgJd6tY4Wc89G0EJDiHF9tYo8F63ytm8,40
|
|
@@ -29,10 +29,10 @@ django_compose/management/commands/migrate.py,sha256=_MkiQRjQRwIr9dEUnKk4WEjLgz5
|
|
|
29
29
|
django_compose/management/commands/provision.py,sha256=4GTPwH1Pp1V_YkztDZxeHuyAjDUHjZxhkdvFlrgDBfU,1035
|
|
30
30
|
django_compose/management/commands/reset_migration_history.py,sha256=Q6ShGeiWOAFS-rZOWuP0lncjwYp9vjRRbaIuk7Aoth0,1428
|
|
31
31
|
django_compose/management/commands/retire_history.py,sha256=3RV1-w5Niij0svr0gB_gAjBgskxCYtdg5pPfsGN287s,886
|
|
32
|
-
django_compose-0.1.0.
|
|
33
|
-
django_compose-0.1.0.
|
|
34
|
-
django_compose-0.1.0.
|
|
35
|
-
django_compose-0.1.0.
|
|
36
|
-
django_compose-0.1.0.
|
|
37
|
-
django_compose-0.1.0.
|
|
38
|
-
django_compose-0.1.0.
|
|
32
|
+
django_compose-0.1.0.dev10.dist-info/METADATA,sha256=YqY1-n40ALXxYhJTJm-GFxuqEqTm4phsydGvSK6OKK8,4152
|
|
33
|
+
django_compose-0.1.0.dev10.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
34
|
+
django_compose-0.1.0.dev10.dist-info/entry_points.txt,sha256=-Iw1c8YAegCC53YCKgPXjIZn4aPS3MmEKbcMrCpUMFU,59
|
|
35
|
+
django_compose-0.1.0.dev10.dist-info/licenses/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
36
|
+
django_compose-0.1.0.dev10.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
37
|
+
django_compose-0.1.0.dev10.dist-info/licenses/NOTICE,sha256=C4fEGI9_-a1GCPfAH9bC0ZvmZFS71b9Z4v6rjrT5dxA,450
|
|
38
|
+
django_compose-0.1.0.dev10.dist-info/RECORD,,
|
|
File without changes
|
{django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|
{django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{django_compose-0.1.0.dev9.dist-info → django_compose-0.1.0.dev10.dist-info}/licenses/NOTICE
RENAMED
|
File without changes
|