dependence 1.1.3__py3-none-any.whl → 1.2.1__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.
- dependence/__main__.py +1 -0
- dependence/_utilities.py +84 -54
- {dependence-1.1.3.dist-info → dependence-1.2.1.dist-info}/METADATA +1 -1
- {dependence-1.1.3.dist-info → dependence-1.2.1.dist-info}/RECORD +6 -6
- {dependence-1.1.3.dist-info → dependence-1.2.1.dist-info}/WHEEL +0 -0
- {dependence-1.1.3.dist-info → dependence-1.2.1.dist-info}/entry_points.txt +0 -0
dependence/__main__.py
CHANGED
dependence/_utilities.py
CHANGED
|
@@ -4,6 +4,7 @@ import functools
|
|
|
4
4
|
import json
|
|
5
5
|
import os
|
|
6
6
|
import re
|
|
7
|
+
import shutil
|
|
7
8
|
import sys
|
|
8
9
|
from collections import deque
|
|
9
10
|
from collections.abc import Container, Hashable, Iterable, MutableSet
|
|
@@ -456,60 +457,66 @@ def iter_configuration_files(path: str | Path) -> Iterable[Path | str]:
|
|
|
456
457
|
yield path
|
|
457
458
|
|
|
458
459
|
|
|
459
|
-
def
|
|
460
|
-
metadata:
|
|
461
|
-
for metadata in
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
sys.executable,
|
|
465
|
-
"-m",
|
|
466
|
-
"pip",
|
|
467
|
-
"list",
|
|
468
|
-
"--editable",
|
|
469
|
-
"--format=json",
|
|
470
|
-
)
|
|
471
|
-
)
|
|
472
|
-
):
|
|
473
|
-
yield (
|
|
474
|
-
normalize_name(metadata["name"]),
|
|
475
|
-
metadata["editable_project_location"],
|
|
460
|
+
def _iter_editable_project_locations() -> Iterable[tuple[str, str]]:
|
|
461
|
+
metadata: PackageMetadata
|
|
462
|
+
for name, metadata in map_pip_list().items():
|
|
463
|
+
editable_project_location: str | None = metadata.get(
|
|
464
|
+
"editable_project_location"
|
|
476
465
|
)
|
|
466
|
+
if editable_project_location:
|
|
467
|
+
yield (
|
|
468
|
+
name,
|
|
469
|
+
editable_project_location,
|
|
470
|
+
)
|
|
477
471
|
|
|
478
472
|
|
|
479
473
|
@functools.lru_cache
|
|
480
|
-
def
|
|
474
|
+
def map_editable_project_locations() -> dict[str, str]:
|
|
481
475
|
"""
|
|
482
476
|
Get a mapping of (normalized) editable distribution names to their
|
|
483
477
|
locations.
|
|
484
478
|
"""
|
|
485
|
-
return dict(
|
|
479
|
+
return dict(_iter_editable_project_locations())
|
|
486
480
|
|
|
487
481
|
|
|
488
|
-
class
|
|
482
|
+
class PackageMetadata(TypedDict, total=False):
|
|
489
483
|
name: str
|
|
490
484
|
version: str
|
|
491
485
|
editable_project_location: str
|
|
492
486
|
|
|
493
487
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
"--format=json",
|
|
506
|
-
)
|
|
488
|
+
def _iter_pip_list() -> Iterable[tuple[str, PackageMetadata]]:
|
|
489
|
+
uv: str | None = shutil.which("uv")
|
|
490
|
+
command: tuple[str, ...]
|
|
491
|
+
if uv:
|
|
492
|
+
command = (
|
|
493
|
+
uv,
|
|
494
|
+
"pip",
|
|
495
|
+
"list",
|
|
496
|
+
"--python",
|
|
497
|
+
sys.executable,
|
|
498
|
+
"--format=json",
|
|
507
499
|
)
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
500
|
+
else:
|
|
501
|
+
# If `uv` is not available, use `pip`
|
|
502
|
+
command = (
|
|
503
|
+
sys.executable,
|
|
504
|
+
"-m",
|
|
505
|
+
"pip",
|
|
506
|
+
"list",
|
|
507
|
+
"--format=json",
|
|
508
|
+
)
|
|
509
|
+
metadata: PackageMetadata
|
|
510
|
+
for metadata in json.loads(check_output(command)):
|
|
511
|
+
yield (
|
|
512
|
+
normalize_name(metadata["name"]),
|
|
513
|
+
metadata,
|
|
511
514
|
)
|
|
512
|
-
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
@cache
|
|
518
|
+
def map_pip_list() -> dict[str, PackageMetadata]:
|
|
519
|
+
return dict(_iter_pip_list())
|
|
513
520
|
|
|
514
521
|
|
|
515
522
|
def cache_clear() -> None:
|
|
@@ -518,7 +525,7 @@ def cache_clear() -> None:
|
|
|
518
525
|
"""
|
|
519
526
|
map_pip_list.cache_clear()
|
|
520
527
|
get_installed_distributions.cache_clear()
|
|
521
|
-
|
|
528
|
+
map_editable_project_locations.cache_clear()
|
|
522
529
|
is_editable.cache_clear()
|
|
523
530
|
is_installed.cache_clear()
|
|
524
531
|
get_requirement_string_distribution_name.cache_clear()
|
|
@@ -530,7 +537,7 @@ def refresh_editable_distributions() -> None:
|
|
|
530
537
|
"""
|
|
531
538
|
name: str
|
|
532
539
|
location: str
|
|
533
|
-
for name, location in
|
|
540
|
+
for name, location in map_editable_project_locations().items():
|
|
534
541
|
_install_requirement_string(location, name=name, editable=True)
|
|
535
542
|
|
|
536
543
|
|
|
@@ -817,7 +824,7 @@ def is_editable(name: str) -> bool:
|
|
|
817
824
|
"""
|
|
818
825
|
Return `True` if the indicated distribution is an editable installation.
|
|
819
826
|
"""
|
|
820
|
-
return bool(normalize_name(name) in
|
|
827
|
+
return bool(normalize_name(name) in map_editable_project_locations())
|
|
821
828
|
|
|
822
829
|
|
|
823
830
|
def _get_setup_cfg_metadata(path: str, key: str) -> str:
|
|
@@ -946,7 +953,7 @@ def _setup_location(
|
|
|
946
953
|
|
|
947
954
|
|
|
948
955
|
def get_editable_distribution_location(name: str) -> str:
|
|
949
|
-
return
|
|
956
|
+
return map_editable_project_locations().get(normalize_name(name), "")
|
|
950
957
|
|
|
951
958
|
|
|
952
959
|
def setup_egg_info(directory: str | Path, egg_base: str = "") -> None:
|
|
@@ -1070,21 +1077,44 @@ def _install_requirement_string(
|
|
|
1070
1077
|
Install a requirement string with no dependencies, compilation, build
|
|
1071
1078
|
isolation, etc.
|
|
1072
1079
|
"""
|
|
1073
|
-
command: tuple[str, ...]
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
"-
|
|
1084
|
-
|
|
1080
|
+
command: tuple[str, ...]
|
|
1081
|
+
uv: str | None = shutil.which("uv")
|
|
1082
|
+
if uv:
|
|
1083
|
+
command = (
|
|
1084
|
+
uv,
|
|
1085
|
+
"pip",
|
|
1086
|
+
"install",
|
|
1087
|
+
"--python",
|
|
1088
|
+
sys.executable,
|
|
1089
|
+
"--no-deps",
|
|
1090
|
+
"--no-compile",
|
|
1091
|
+
*(
|
|
1092
|
+
(
|
|
1093
|
+
"-e",
|
|
1094
|
+
requirement_string,
|
|
1095
|
+
)
|
|
1096
|
+
if editable
|
|
1097
|
+
else (requirement_string,)
|
|
1098
|
+
),
|
|
1085
1099
|
)
|
|
1086
1100
|
else:
|
|
1087
|
-
|
|
1101
|
+
# If `uv` is not available, use `pip`
|
|
1102
|
+
command = (
|
|
1103
|
+
sys.executable,
|
|
1104
|
+
"-m",
|
|
1105
|
+
"pip",
|
|
1106
|
+
"install",
|
|
1107
|
+
"--no-deps",
|
|
1108
|
+
"--no-compile",
|
|
1109
|
+
*(
|
|
1110
|
+
(
|
|
1111
|
+
"-e",
|
|
1112
|
+
requirement_string,
|
|
1113
|
+
)
|
|
1114
|
+
if editable
|
|
1115
|
+
else (requirement_string,)
|
|
1116
|
+
),
|
|
1117
|
+
)
|
|
1088
1118
|
try:
|
|
1089
1119
|
check_output(command)
|
|
1090
1120
|
except CalledProcessError as error:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
dependence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
dependence/__main__.py,sha256=
|
|
3
|
-
dependence/_utilities.py,sha256
|
|
2
|
+
dependence/__main__.py,sha256=gsluad-hgMvktrflSNLEMB3F-G_BKvlIGTHL0c1aQd8,1822
|
|
3
|
+
dependence/_utilities.py,sha256=-9RGMsQKzaA-fEDswdXSx1LAVKdasWuKQGl7jgTeZXs,38960
|
|
4
4
|
dependence/freeze.py,sha256=dW3m2zEf2l61GWKdQTgrvj8FCDINU6GahmKr5ViIKX4,16226
|
|
5
5
|
dependence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
dependence/update.py,sha256=043Hsj8bQJypJ_p_dxSl8HXBwlGoUK238OFYThTWVos,20856
|
|
7
7
|
dependence/upgrade.py,sha256=lNovLvKhxiczZAJj2_hHrbkDscNOTrx1xaOhmobVNSI,7747
|
|
8
|
-
dependence-1.1.
|
|
9
|
-
dependence-1.1.
|
|
10
|
-
dependence-1.1.
|
|
11
|
-
dependence-1.1.
|
|
8
|
+
dependence-1.2.1.dist-info/METADATA,sha256=HWFQjpA3poRTZLCAqNHgDf36iVrYDZmD0PrDQinQLtw,8364
|
|
9
|
+
dependence-1.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
+
dependence-1.2.1.dist-info/entry_points.txt,sha256=NStO_B0D81ObVYr9zDs6LCy0whm0a8KCiiFHMmTwOVE,56
|
|
11
|
+
dependence-1.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|