dependence 1.2.1__py3-none-any.whl → 1.2.5__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/_utilities.py CHANGED
@@ -7,8 +7,6 @@ import re
7
7
  import shutil
8
8
  import sys
9
9
  from collections import deque
10
- from collections.abc import Container, Hashable, Iterable, MutableSet
11
- from collections.abc import Set as AbstractSet
12
10
  from configparser import ConfigParser, SectionProxy
13
11
  from enum import Enum, auto
14
12
  from glob import iglob
@@ -22,8 +20,8 @@ from subprocess import DEVNULL, PIPE, CalledProcessError, list2cmdline, run
22
20
  from traceback import format_exception
23
21
  from typing import (
24
22
  IO,
23
+ TYPE_CHECKING,
25
24
  Any,
26
- Callable,
27
25
  TypedDict,
28
26
  cast,
29
27
  overload,
@@ -35,6 +33,18 @@ from jsonpointer import resolve_pointer # type: ignore
35
33
  from packaging.requirements import InvalidRequirement, Requirement
36
34
  from packaging.utils import canonicalize_name
37
35
 
36
+ if TYPE_CHECKING:
37
+ from collections.abc import (
38
+ Callable,
39
+ Container,
40
+ Hashable,
41
+ Iterable,
42
+ MutableSet,
43
+ )
44
+ from collections.abc import (
45
+ Set as AbstractSet,
46
+ )
47
+
38
48
  _BUILTIN_DISTRIBUTION_NAMES: tuple[str] = ("distribute",)
39
49
  _UNSAFE_CHARACTERS_PATTERN: re.Pattern = re.compile("[^A-Za-z0-9.]+")
40
50
 
@@ -1246,7 +1256,7 @@ def _iter_requirement_names(
1246
1256
  yield from _iter_requirement_names(
1247
1257
  requirement_,
1248
1258
  exclude=cast(
1249
- MutableSet[str],
1259
+ "MutableSet[str]",
1250
1260
  exclude
1251
1261
  | (
1252
1262
  lateral_exclude - {_get_requirement_name(requirement_)}
dependence/freeze.py CHANGED
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  import argparse
4
4
  import os
5
- from collections.abc import Iterable, MutableSet
6
5
  from fnmatch import fnmatch
7
6
  from functools import partial
8
7
  from itertools import chain
@@ -21,6 +20,7 @@ from dependence._utilities import (
21
20
  )
22
21
 
23
22
  if TYPE_CHECKING:
23
+ from collections.abc import Iterable, MutableSet
24
24
  from importlib.metadata import Distribution
25
25
 
26
26
  _DO_NOT_PIN_DISTRIBUTION_NAMES: MutableSet[str] = {
@@ -81,6 +81,7 @@ def get_frozen_requirements( # noqa: C901
81
81
  *,
82
82
  exclude: Iterable[str] = (),
83
83
  exclude_recursive: Iterable[str] = (),
84
+ keep_version_specifier: Iterable[str] = (),
84
85
  no_version: Iterable[str] = (),
85
86
  dependency_order: bool = False,
86
87
  reverse: bool = False,
@@ -101,8 +102,14 @@ def get_frozen_requirements( # noqa: C901
101
102
  exclude_recursive: One or more distributions to exclude/ignore.
102
103
  Note: Excluding a distribution here excludes all requirements which
103
104
  would be identified through recursion.
105
+ keep_version_specifier: Keep the original (non-frozen) version
106
+ specifier for package names matching any of these patterns. This
107
+ supercedes `no_version`, if both sets of patterns match a package
108
+ name.
104
109
  no_version: Exclude version numbers from the output
105
- (only return distribution names)
110
+ (only return distribution names). This is superceded by
111
+ `keep_version_specifier`, if both sets of patterns match a package
112
+ name.
106
113
  dependency_order: Sort requirements so that dependents
107
114
  precede dependencies
108
115
  depth: Depth of recursive requirement discovery
@@ -119,6 +126,10 @@ def get_frozen_requirements( # noqa: C901
119
126
  no_version = (no_version,)
120
127
  elif not isinstance(no_version, tuple):
121
128
  no_version = tuple(no_version)
129
+ if isinstance(keep_version_specifier, str):
130
+ keep_version_specifier = (keep_version_specifier,)
131
+ elif not isinstance(keep_version_specifier, tuple):
132
+ keep_version_specifier = tuple(keep_version_specifier)
122
133
  # Separate requirement strings from requirement files
123
134
  configuration_files: dict[str, dict[str, tuple[str, ...]]] = {}
124
135
  requirement_strings: MutableSet[str] = set()
@@ -191,6 +202,7 @@ def get_frozen_requirements( # noqa: C901
191
202
  ),
192
203
  exclude_recursive=set(map(normalize_name, exclude_recursive)),
193
204
  no_version=no_version,
205
+ keep_version_specifier=keep_version_specifier,
194
206
  depth=depth,
195
207
  )
196
208
  if dependency_order:
@@ -217,13 +229,20 @@ def _iter_frozen_requirements(
217
229
  exclude_recursive: MutableSet[str],
218
230
  no_version: Iterable[str] = (),
219
231
  depth: int | None = None,
232
+ keep_version_specifier: Iterable[str] = (),
220
233
  ) -> Iterable[str]:
221
- def get_requirement_string(distribution_name: str) -> str | None:
222
- def distribution_name_matches_pattern(pattern: str) -> bool:
223
- return fnmatch(distribution_name, pattern)
234
+ # This retains a mapping of distribution names to their original
235
+ # requirement strings in order to return those which match
236
+ # `keep_version_specifier` patterns with their original specifiers
237
+ distribution_names_specifiers: dict[str, str] = {}
224
238
 
239
+ def get_requirement_string(distribution_name: str) -> str | None:
240
+ if distribution_names_specifiers and (
241
+ distribution_name in distribution_names_specifiers
242
+ ):
243
+ return distribution_names_specifiers[distribution_name]
225
244
  if (distribution_name in _DO_NOT_PIN_DISTRIBUTION_NAMES) or any(
226
- map(distribution_name_matches_pattern, no_version)
245
+ fnmatch(distribution_name, pattern) for pattern in no_version
227
246
  ):
228
247
  return distribution_name
229
248
  distribution: Distribution
@@ -246,6 +265,10 @@ def _iter_frozen_requirements(
246
265
  )
247
266
  if name in exclude_recursive:
248
267
  return set()
268
+ if keep_version_specifier and any(
269
+ fnmatch(name, pattern) for pattern in keep_version_specifier
270
+ ):
271
+ distribution_names_specifiers[name] = requirement_string.rstrip()
249
272
  distribution_names: MutableSet[str] = {name}
250
273
  if (depth_ is None) or depth_:
251
274
  distribution_names |= get_required_distribution_names(
@@ -254,7 +277,7 @@ def _iter_frozen_requirements(
254
277
  depth=None if (depth_ is None) else depth_ - 1,
255
278
  )
256
279
  return cast(
257
- MutableSet[str],
280
+ "MutableSet[str]",
258
281
  distribution_names - exclude,
259
282
  )
260
283
 
dependence/update.py CHANGED
@@ -13,7 +13,6 @@ from typing import (
13
13
  IO,
14
14
  TYPE_CHECKING,
15
15
  Any,
16
- Callable,
17
16
  )
18
17
 
19
18
  import tomli
@@ -35,7 +34,7 @@ from dependence._utilities import (
35
34
  )
36
35
 
37
36
  if TYPE_CHECKING:
38
- from collections.abc import Iterable
37
+ from collections.abc import Callable, Iterable
39
38
  from importlib.metadata import Distribution
40
39
 
41
40
 
dependence/upgrade.py CHANGED
@@ -27,6 +27,7 @@ def upgrade(
27
27
  exclude: Iterable[str] = (),
28
28
  exclude_recursive: Iterable[str] = (),
29
29
  depth: int | None = None,
30
+ echo: bool = False,
30
31
  ) -> None:
31
32
  """
32
33
  This function obtains a list of dependencies for the specified
@@ -72,20 +73,22 @@ def upgrade(
72
73
  requirements,
73
74
  exclude=exclude,
74
75
  exclude_recursive=exclude_recursive,
76
+ keep_version_specifier="*",
75
77
  no_version="*",
76
78
  depth=depth,
77
79
  include_pointers=include_pointers,
78
80
  exclude_pointers=exclude_pointers,
79
81
  )
80
- command: tuple[str, ...] = (
81
- sys.executable,
82
- "-m",
83
- "pip",
84
- "install",
85
- "--upgrade",
86
- *frozen_requirements,
87
- )
88
- check_output(command)
82
+ if frozen_requirements:
83
+ command: tuple[str, ...] = (
84
+ sys.executable,
85
+ "-m",
86
+ "pip",
87
+ "install",
88
+ "--upgrade",
89
+ *frozen_requirements,
90
+ )
91
+ check_output(command, echo=echo)
89
92
  configuration_files: tuple[str, ...] = tuple(
90
93
  chain(
91
94
  *map(iter_configuration_files, requirements) # type: ignore
@@ -1,19 +1,19 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependence
3
- Version: 1.2.1
3
+ Version: 1.2.5
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
7
7
  Author-email: david@belais.me
8
8
  License-Expression: MIT
9
9
  Keywords: dependencies,requirements
10
- Requires-Python: ~=3.9
10
+ Requires-Python: ~=3.10
11
11
  Requires-Dist: jsonpointer
12
12
  Requires-Dist: packaging
13
13
  Requires-Dist: pip
14
14
  Requires-Dist: setuptools>63
15
15
  Requires-Dist: tomli-w~=1.2
16
- Requires-Dist: tomli~=2.2
16
+ Requires-Dist: tomli~=2.3
17
17
  Description-Content-Type: text/markdown
18
18
 
19
19
  # dependence
@@ -59,7 +59,7 @@ For example, in [this project's Makefile
59
59
 
60
60
  ```Makefile
61
61
  SHELL := bash
62
- PYTHON_VERSION := 3.9
62
+ PYTHON_VERSION := 3.10
63
63
 
64
64
  upgrade:
65
65
  hatch run dependence upgrade\
@@ -0,0 +1,11 @@
1
+ dependence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ dependence/__main__.py,sha256=gsluad-hgMvktrflSNLEMB3F-G_BKvlIGTHL0c1aQd8,1822
3
+ dependence/_utilities.py,sha256=tcDRdDNdxeZHmqqHD7tynNSQYfZ9RWp0b7JiKfw88jE,39070
4
+ dependence/freeze.py,sha256=ybjHOQOzxtuVjJQOUr1077CoMGSGdho3iKj8waygwuQ,17516
5
+ dependence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ dependence/update.py,sha256=KGNj-COhRnbxGVAUikBKdUgJCz0xZ741Z6HEBny7diQ,20852
7
+ dependence/upgrade.py,sha256=nyOahgBJayeVeicM4AJ72lp2uDMvJOcCNUZIhVKk1do,7882
8
+ dependence-1.2.5.dist-info/METADATA,sha256=app1ZrC3g853fvygMzm15hHB4CaCpfMnxnuHS8TZ6kg,8366
9
+ dependence-1.2.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ dependence-1.2.5.dist-info/entry_points.txt,sha256=NStO_B0D81ObVYr9zDs6LCy0whm0a8KCiiFHMmTwOVE,56
11
+ dependence-1.2.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,11 +0,0 @@
1
- dependence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- dependence/__main__.py,sha256=gsluad-hgMvktrflSNLEMB3F-G_BKvlIGTHL0c1aQd8,1822
3
- dependence/_utilities.py,sha256=-9RGMsQKzaA-fEDswdXSx1LAVKdasWuKQGl7jgTeZXs,38960
4
- dependence/freeze.py,sha256=dW3m2zEf2l61GWKdQTgrvj8FCDINU6GahmKr5ViIKX4,16226
5
- dependence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- dependence/update.py,sha256=043Hsj8bQJypJ_p_dxSl8HXBwlGoUK238OFYThTWVos,20856
7
- dependence/upgrade.py,sha256=lNovLvKhxiczZAJj2_hHrbkDscNOTrx1xaOhmobVNSI,7747
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,,