dependence 1.4.2__tar.gz → 1.4.4__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
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: dependence
3
- Version: 1.4.2
3
+ Version: 1.4.4
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
@@ -8,9 +8,9 @@ Author-email: david@belais.me
8
8
  License-Expression: MIT
9
9
  Keywords: dependencies,requirements
10
10
  Requires-Python: ~=3.10
11
- Requires-Dist: jsonpointer
12
- Requires-Dist: packaging
13
- Requires-Dist: pip
11
+ Requires-Dist: jsonpointer<4
12
+ Requires-Dist: packaging<27,>23
13
+ Requires-Dist: pip>23
14
14
  Requires-Dist: setuptools>63
15
15
  Requires-Dist: tomli-w~=1.2
16
16
  Requires-Dist: tomli~=2.4
@@ -550,6 +550,9 @@ def is_aliased(command: str) -> bool:
550
550
  try:
551
551
  shell_output: str = check_output( # noqa: S604
552
552
  (WHICH, command),
553
+ # This must run in the user's actual
554
+ # shell to detect shell aliases/functions; there is no
555
+ # non-shell equivalent for this check
553
556
  shell=True,
554
557
  )
555
558
  except CalledProcessError:
@@ -578,10 +581,14 @@ def _iter_pip_list() -> Iterable[tuple[str, PackageMetadata]]:
578
581
  )
579
582
  try:
580
583
  output = check_output(uv_command)
581
- except CalledProcessError:
582
- # `uv` was found on `PATH` but could not run (for example, a
583
- # CI security wrapper's shim with no real `uv` to delegate
584
- # to) -- fall back to this interpreter's own `pip`.
584
+ except (CalledProcessError, OSError):
585
+ # `uv` was found on `PATH` but could not run -- either it
586
+ # ran and exited non-zero (for example, a CI security
587
+ # wrapper's shim with no real `uv` to delegate to,
588
+ # `CalledProcessError`), or it could not be executed at
589
+ # all (a dangling shebang, a corrupted binary, or a
590
+ # permission error, `OSError`) -- fall back to this
591
+ # interpreter's own `pip`.
585
592
  output = check_output(pip_command)
586
593
  else:
587
594
  output = check_output(pip_command)
@@ -905,7 +912,7 @@ def is_editable(name: str) -> bool:
905
912
  """
906
913
  Return `True` if the indicated distribution is an editable installation.
907
914
  """
908
- return bool(normalize_name(name) in map_editable_project_locations())
915
+ return normalize_name(name) in map_editable_project_locations()
909
916
 
910
917
 
911
918
  def _get_setup_cfg_metadata(path: str, key: str) -> str:
@@ -1023,8 +1030,6 @@ def _setup_location(
1023
1030
  # If there is no setup.py file, we can't update egg info
1024
1031
  if not location.joinpath("setup.py").is_file():
1025
1032
  return
1026
- if isinstance(arguments, str):
1027
- arguments = (arguments,)
1028
1033
  current_directory: Path = Path(os.curdir).absolute()
1029
1034
  os.chdir(location)
1030
1035
  try:
@@ -1148,6 +1153,24 @@ def install_requirement(requirement: str | Requirement) -> None:
1148
1153
  return _install_requirement(requirement)
1149
1154
 
1150
1155
 
1156
+ def _raise_oserror(
1157
+ error: CalledProcessError | OSError,
1158
+ ) -> CalledProcessError:
1159
+ """
1160
+ Used by `_install_requirement_string` when there is no `uv`
1161
+ fallback to attempt (`uv` was absent from `PATH`, so `error` is
1162
+ this interpreter's own `pip` failing on its sole attempt): if
1163
+ `error` is an `OSError`, there is no `.output` to report via the
1164
+ caller's message construction, so re-raise it as-is. A
1165
+ `CalledProcessError` is exactly what `_install_requirement_string`
1166
+ already raised before its `uv` fallback existed, so it is returned
1167
+ unchanged for the caller to handle the same way as before.
1168
+ """
1169
+ if isinstance(error, OSError):
1170
+ raise error
1171
+ return error
1172
+
1173
+
1151
1174
  def _install_requirement_string(
1152
1175
  requirement_string: str,
1153
1176
  name: str = "",
@@ -1214,17 +1237,19 @@ def _install_requirement_string(
1214
1237
  )
1215
1238
  try:
1216
1239
  check_output(command, shell=shell)
1217
- except CalledProcessError as uv_error:
1218
- # Reassigned below if the `pip` fallback also fails, so the
1219
- # rest of this handler (including the bare re-raise) reports
1220
- # whichever command actually produced the *last* failure.
1221
- # Keep this as `except ... as uv_error` + assignment (not
1222
- # `except ... as error`) -- `error` is deliberately mutable.
1223
- error: CalledProcessError = uv_error
1240
+ except (CalledProcessError, OSError) as uv_error:
1241
+ # Reassigned below if `uv` was attempted and the `pip`
1242
+ # fallback also fails, so the rest of this handler (including
1243
+ # the bare re-raise) reports whichever command actually
1244
+ # produced the *last* failure.
1245
+ error: CalledProcessError
1224
1246
  if uv:
1225
- # `uv` was found on `PATH` but could not run (for example, a
1226
- # CI security wrapper's shim with no real `uv` to delegate
1227
- # to) -- fall back to this interpreter's own `pip`.
1247
+ # `uv` was found on `PATH` but failed -- either it ran and
1248
+ # exited non-zero (`CalledProcessError`, for example a CI
1249
+ # security wrapper's shim with no real `uv` to delegate
1250
+ # to) or it could not be executed at all (`OSError`: a
1251
+ # dangling shebang, a corrupted binary, or a permission
1252
+ # error) -- fall back to this interpreter's own `pip`.
1228
1253
  pip_command: tuple[str, ...] = (
1229
1254
  sys.executable,
1230
1255
  "-m",
@@ -1245,6 +1270,10 @@ def _install_requirement_string(
1245
1270
  error = pip_error
1246
1271
  else:
1247
1272
  return
1273
+ else:
1274
+ # No `uv` was attempted (`command` is already the `pip`
1275
+ # command) -- there is nothing to fall back to.
1276
+ error = _raise_oserror(uv_error)
1248
1277
  message: str = (
1249
1278
  (
1250
1279
  f"\nCould not install {name}:"
@@ -5,7 +5,6 @@ import re
5
5
  from collections import deque
6
6
  from configparser import ConfigParser, SectionProxy
7
7
  from copy import deepcopy
8
- from dataclasses import dataclass
9
8
  from fnmatch import fnmatch
10
9
  from io import StringIO
11
10
  from itertools import chain
@@ -14,6 +13,7 @@ from typing import (
14
13
  IO,
15
14
  TYPE_CHECKING,
16
15
  Any,
16
+ cast,
17
17
  )
18
18
 
19
19
  import tomli
@@ -39,22 +39,6 @@ if TYPE_CHECKING:
39
39
  from importlib.metadata import Distribution
40
40
 
41
41
 
42
- @dataclass
43
- class _Version:
44
- """
45
- Instances of this class can be be passed as `self` in a call
46
- to `packaging.version.Version.__str__`, and thereby can facilitate
47
- operations to mimic mutability for the aforementioned class.
48
- """
49
-
50
- epoch: int
51
- release: tuple[int, ...]
52
- pre: Any
53
- post: Any
54
- dev: Any
55
- local: Any
56
-
57
-
58
42
  def _update_requirement_specifiers(
59
43
  requirement: Requirement, installed_version_string: str
60
44
  ) -> None:
@@ -75,40 +59,29 @@ def _update_requirement_specifiers(
75
59
  if specifier_version.release is None:
76
60
  updated_specifier_strings.append(f"{specifier.operator}")
77
61
  else:
78
- greater_or_equal_specificity: bool = len(
79
- specifier_version.release
80
- ) >= len(installed_version.release)
81
- specifier_version_data: _Version = _Version(
82
- epoch=installed_version.epoch,
83
- # Truncate the updated version requirement at the same
84
- # level of specificity as the old
85
- release=installed_version.release[
86
- : len(specifier_version.release)
87
- ],
88
- pre=(
89
- installed_version.pre
90
- if greater_or_equal_specificity
91
- else None
92
- ),
93
- post=(
94
- installed_version.post
95
- if greater_or_equal_specificity
96
- else None
97
- ),
98
- dev=(
99
- installed_version.dev
100
- if greater_or_equal_specificity
101
- else None
102
- ),
103
- local=(
104
- installed_version.local
105
- if greater_or_equal_specificity
106
- else None
107
- ),
108
- )
109
- version_string: str = Version.__str__(
110
- specifier_version_data # type: ignore
62
+ # Only equality specifiers permit local version identifiers.
63
+ version_string: str = (
64
+ str(installed_version)
65
+ if specifier.operator in ("==", "===")
66
+ else installed_version.public
111
67
  )
68
+ if len(specifier_version.release) < len(
69
+ installed_version.release
70
+ ):
71
+ # Truncate to the original release precision, dropping
72
+ # suffixes that apply only to the full release.
73
+ version_string = ".".join(
74
+ map(
75
+ str,
76
+ installed_version.release[
77
+ : len(specifier_version.release)
78
+ ],
79
+ )
80
+ )
81
+ if installed_version.epoch:
82
+ version_string = (
83
+ f"{installed_version.epoch}!{version_string}"
84
+ )
112
85
  updated_specifier_strings.append(
113
86
  f"{specifier.operator}{version_string}"
114
87
  )
@@ -132,8 +105,9 @@ def _get_updated_requirement_string(
132
105
  pattern: str
133
106
  if ignore and any(fnmatch(name, pattern) for pattern in ignore):
134
107
  return requirement_string
108
+ distribution: Distribution | None = None
135
109
  try:
136
- distribution: Distribution = get_installed_distributions()[name]
110
+ distribution = get_installed_distributions()[name]
137
111
  if distribution.version is None:
138
112
  return requirement_string
139
113
  _update_requirement_specifiers(requirement, distribution.version)
@@ -432,32 +406,43 @@ def _update(
432
406
  ) -> None:
433
407
  message: str
434
408
  data: str
435
- update_function: Callable[[str], str]
409
+ # Each branch below assigns a function with a different keyword
410
+ # argument set (some accept `all_extra_name`/`include_pointers`/
411
+ # `exclude_pointers`, others don't), each paired with exactly the
412
+ # kwargs it accepts -- correct by construction, but not something
413
+ # the type checker can verify across a shared `**kwargs` dict, so
414
+ # each assignment is cast to the common `Callable[..., str]` shape
415
+ # rather than left to narrow back to its own literal signature.
416
+ update_function: Callable[..., str]
436
417
  kwargs: dict[str, str | Iterable[str]] = {}
437
418
  configuration_file_type: ConfigurationFileType = (
438
419
  get_configuration_file_type(path)
439
420
  )
440
421
  if configuration_file_type == ConfigurationFileType.SETUP_CFG:
441
- update_function = _get_updated_setup_cfg
422
+ update_function = cast("Callable[..., str]", _get_updated_setup_cfg)
442
423
  if all_extra_name:
443
424
  kwargs["all_extra_name"] = all_extra_name
444
425
  elif configuration_file_type == ConfigurationFileType.PYPROJECT_TOML:
445
- update_function = _get_updated_pyproject_toml
426
+ update_function = cast(
427
+ "Callable[..., str]", _get_updated_pyproject_toml
428
+ )
446
429
  kwargs.update(
447
430
  all_extra_name=all_extra_name,
448
431
  include_pointers=include_pointers,
449
432
  exclude_pointers=exclude_pointers,
450
433
  )
451
434
  elif configuration_file_type == ConfigurationFileType.TOML:
452
- update_function = _get_updated_toml
435
+ update_function = cast("Callable[..., str]", _get_updated_toml)
453
436
  kwargs.update(
454
437
  include_pointers=include_pointers,
455
438
  exclude_pointers=exclude_pointers,
456
439
  )
457
440
  elif configuration_file_type == ConfigurationFileType.TOX_INI:
458
- update_function = _get_updated_tox_ini
441
+ update_function = cast("Callable[..., str]", _get_updated_tox_ini)
459
442
  elif configuration_file_type == ConfigurationFileType.REQUIREMENTS_TXT:
460
- update_function = _get_updated_requirements_txt
443
+ update_function = cast(
444
+ "Callable[..., str]", _get_updated_requirements_txt
445
+ )
461
446
  else:
462
447
  message = f"Updating requirements for {path!s} is not supported"
463
448
  raise NotImplementedError(message)
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "dependence"
9
- version = "1.4.2"
9
+ version = "1.4.4"
10
10
  description = "A dependency management tool for python projects"
11
11
  readme = "README.md"
12
12
  license = "MIT"
@@ -19,12 +19,12 @@ keywords = [
19
19
  "requirements",
20
20
  ]
21
21
  dependencies = [
22
- "packaging",
23
- "pip",
22
+ "packaging>23,<27",
23
+ "pip>23",
24
24
  "setuptools>63",
25
25
  "tomli-w~=1.2",
26
26
  "tomli~=2.4",
27
- "jsonpointer",
27
+ "jsonpointer<4",
28
28
  ]
29
29
 
30
30
  [project.scripts]
@@ -54,16 +54,12 @@ src = ""
54
54
  path = ".venv"
55
55
  python = "3.10"
56
56
  dependencies = [
57
- "mypy",
58
57
  "pytest",
59
58
  "ruff",
60
59
  ]
61
60
  pre-install-commands = [
62
61
  "uv pip install --upgrade pip setuptools",
63
62
  ]
64
- post-install-commands = [
65
- "hatch run mypy --install-types --non-interactive || echo",
66
- ]
67
63
 
68
64
  [tool.hatch.envs.docs]
69
65
  template = "docs"
@@ -79,9 +75,9 @@ skip-install = false
79
75
 
80
76
  [tool.hatch.envs.hatch-test]
81
77
  template = "hatch-test"
78
+ matrix-name-format = "{variable}{value}"
82
79
  extra-dependencies = [
83
80
  "ruff",
84
- "mypy",
85
81
  "flake8",
86
82
  "tox",
87
83
  "black",
@@ -92,12 +88,87 @@ extra-args = [
92
88
  "-vv",
93
89
  ]
94
90
 
91
+ [tool.hatch.envs.hatch-test.overrides]
92
+ matrix.packaging.extra-dependencies = ["packaging=={matrix:packaging}.*"]
93
+ matrix.packaging.env-vars = [
94
+ "DEPENDENCE_TEST_REQUIREMENT=packaging=={matrix:packaging}.*",
95
+ ]
96
+ matrix.pip.extra-dependencies = ["pip=={matrix:pip}.*"]
97
+ matrix.pip.env-vars = [
98
+ "DEPENDENCE_TEST_REQUIREMENT=pip=={matrix:pip}.*",
99
+ ]
100
+ matrix.setuptools.extra-dependencies = ["setuptools=={matrix:setuptools}.*"]
101
+ matrix.setuptools.env-vars = [
102
+ "DEPENDENCE_TEST_REQUIREMENT=setuptools=={matrix:setuptools}.*",
103
+ ]
104
+ matrix.jsonpointer.extra-dependencies = ["jsonpointer=={matrix:jsonpointer}.*"]
105
+ matrix.jsonpointer.env-vars = [
106
+ "DEPENDENCE_TEST_REQUIREMENT=jsonpointer=={matrix:jsonpointer}.*",
107
+ ]
108
+
95
109
  [[tool.hatch.envs.hatch-test.matrix]]
96
110
  python = [
97
111
  "3.10",
98
112
  "3.11",
99
113
  "3.12",
100
114
  "3.13",
115
+ "3.14",
116
+ "3.15",
117
+ ]
118
+
119
+ # Exercise dependency majors independently on the oldest supported Python.
120
+ [[tool.hatch.envs.hatch-test.matrix]]
121
+ python = ["3.11"]
122
+ packaging = [
123
+ "23",
124
+ "24",
125
+ "25",
126
+ "26",
127
+ ]
128
+
129
+ [[tool.hatch.envs.hatch-test.matrix]]
130
+ python = ["3.11"]
131
+ pip = [
132
+ "23",
133
+ "24",
134
+ "25",
135
+ "26",
136
+ ]
137
+
138
+ [[tool.hatch.envs.hatch-test.matrix]]
139
+ python = ["3.11"]
140
+ setuptools = [
141
+ "63",
142
+ "64",
143
+ "65",
144
+ "66",
145
+ "67",
146
+ "68",
147
+ "69",
148
+ "70",
149
+ "71",
150
+ "72",
151
+ "73",
152
+ "74",
153
+ "75",
154
+ "76",
155
+ "77",
156
+ "78",
157
+ "79",
158
+ "80",
159
+ "81",
160
+ "82",
161
+ "83",
162
+ "84",
163
+ ]
164
+
165
+ [[tool.hatch.envs.hatch-test.matrix]]
166
+ python = ["3.11"]
167
+ jsonpointer = [
168
+ "0",
169
+ "1",
170
+ "2",
171
+ "3",
101
172
  ]
102
173
 
103
174
  [tool.ruff]
@@ -136,17 +207,17 @@ target-version = [
136
207
  "py313",
137
208
  ]
138
209
 
139
- [tool.mypy]
140
- python_version = "3.10"
141
- files = [
210
+ [tool.pyrefly]
211
+ project-includes = [
142
212
  "src",
143
213
  "tests",
144
214
  ]
145
- exclude = [
146
- "tests/test_projects",
215
+ project-excludes = [
216
+ "**/tests/test_projects*",
147
217
  ]
148
- disallow_untyped_defs = true
149
- disallow_incomplete_defs = true
218
+ python-version = "3.10.0"
219
+ check-unannotated-defs = true
220
+ infer-return-types = "never"
150
221
 
151
222
  [tool.coverage.run]
152
223
  include = [
File without changes
File without changes