dependence 1.1.3__tar.gz → 1.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependence
3
- Version: 1.1.3
3
+ Version: 1.2.0
4
4
  Summary: A dependency management tool for python projects
5
5
  Project-URL: Documentation, https://dependence.enorganic.org
6
6
  Project-URL: Repository, https://github.com/enorganic/dependence
@@ -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 _iter_editable_distribution_locations() -> Iterable[tuple[str, str]]:
460
- metadata: _PackageMetadata
461
- for metadata in json.loads(
462
- check_output(
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 get_editable_distributions_locations() -> dict[str, str]:
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(_iter_editable_distribution_locations())
479
+ return dict(_iter_editable_project_locations())
486
480
 
487
481
 
488
- class _PackageMetadata(TypedDict, total=False):
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
- @cache
495
- def map_pip_list() -> dict[str, _PackageMetadata]:
496
- names_package_metadata: dict[str, _PackageMetadata] = {}
497
- package_metadata: _PackageMetadata
498
- for package_metadata in json.loads(
499
- check_output(
500
- (
501
- sys.executable,
502
- "-m",
503
- "pip",
504
- "list",
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
- names_package_metadata[normalize_name(package_metadata["name"])] = (
510
- package_metadata
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
- return names_package_metadata
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
- get_editable_distributions_locations.cache_clear()
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 get_editable_distributions_locations().items():
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 get_editable_distributions_locations())
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 get_editable_distributions_locations().get(normalize_name(name), "")
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
- sys.executable,
1075
- "-m",
1076
- "pip",
1077
- "install",
1078
- "--no-deps",
1079
- "--no-compile",
1080
- )
1081
- if editable:
1082
- command += (
1083
- "-e",
1084
- requirement_string,
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
- command += (requirement_string,)
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:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "dependence"
7
- version = "1.1.3"
7
+ version = "1.2.0"
8
8
  description = "A dependency management tool for python projects"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -29,11 +29,15 @@ Repository = "https://github.com/enorganic/dependence"
29
29
 
30
30
  [tool.hatch.build.targets.sdist]
31
31
  packages = ["src/dependence"]
32
- sources = ["src"]
32
+
33
+ [tool.hatch.build.targets.sdist.sources]
34
+ src = ""
33
35
 
34
36
  [tool.hatch.build.targets.wheel]
35
37
  packages = ["src/dependence"]
36
- sources = ["src"]
38
+
39
+ [tool.hatch.build.targets.wheel.sources]
40
+ src = ""
37
41
 
38
42
  [tool.hatch.envs.default]
39
43
  python = "3.9"
@@ -56,7 +60,7 @@ skip-install = false
56
60
 
57
61
  [tool.hatch.envs.hatch-test]
58
62
  template = "hatch-test"
59
- extra-dependencies = []
63
+ extra-dependencies = ["ruff", "mypy", "flake8", "tox", "black"]
60
64
  extra-arguments = ["--cache-clear"]
61
65
 
62
66
  [[tool.hatch.envs.hatch-test.matrix]]
File without changes
File without changes