nab-python 0.0.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.
Files changed (71) hide show
  1. nab_python/__init__.py +1 -0
  2. nab_python/_build/__init__.py +1 -0
  3. nab_python/_build/env.py +364 -0
  4. nab_python/_build/errors.py +17 -0
  5. nab_python/_build/runner.py +254 -0
  6. nab_python/_lockfile/__init__.py +1 -0
  7. nab_python/_lockfile/builder.py +339 -0
  8. nab_python/_lockfile/disjointness.py +207 -0
  9. nab_python/_lockfile/pylock.py +323 -0
  10. nab_python/_lockfile/requirements.py +121 -0
  11. nab_python/_packaging_provider.py +98 -0
  12. nab_python/_provider/__init__.py +1 -0
  13. nab_python/_provider/build_remote.py +95 -0
  14. nab_python/_provider/extras.py +231 -0
  15. nab_python/_provider/listing.py +442 -0
  16. nab_python/_provider/lookahead.py +156 -0
  17. nab_python/_provider/metadata_resolver.py +450 -0
  18. nab_python/_provider/priority.py +174 -0
  19. nab_python/_provider/sources.py +215 -0
  20. nab_python/_testing/__init__.py +1 -0
  21. nab_python/_testing/coordinator_fake.py +240 -0
  22. nab_python/_vcs_admission.py +209 -0
  23. nab_python/_vendor/__init__.py +6 -0
  24. nab_python/_vendor/packaging/LICENSE +3 -0
  25. nab_python/_vendor/packaging/LICENSE.APACHE +177 -0
  26. nab_python/_vendor/packaging/LICENSE.BSD +23 -0
  27. nab_python/_vendor/packaging/PROVENANCE.md +73 -0
  28. nab_python/_vendor/packaging/__init__.py +15 -0
  29. nab_python/_vendor/packaging/_elffile.py +108 -0
  30. nab_python/_vendor/packaging/_manylinux.py +265 -0
  31. nab_python/_vendor/packaging/_musllinux.py +88 -0
  32. nab_python/_vendor/packaging/_parser.py +394 -0
  33. nab_python/_vendor/packaging/_structures.py +33 -0
  34. nab_python/_vendor/packaging/_tokenizer.py +196 -0
  35. nab_python/_vendor/packaging/dependency_groups.py +302 -0
  36. nab_python/_vendor/packaging/direct_url.py +325 -0
  37. nab_python/_vendor/packaging/errors.py +94 -0
  38. nab_python/_vendor/packaging/licenses/__init__.py +186 -0
  39. nab_python/_vendor/packaging/licenses/_spdx.py +799 -0
  40. nab_python/_vendor/packaging/markers.py +506 -0
  41. nab_python/_vendor/packaging/metadata.py +964 -0
  42. nab_python/_vendor/packaging/py.typed +0 -0
  43. nab_python/_vendor/packaging/pylock.py +910 -0
  44. nab_python/_vendor/packaging/ranges.py +1803 -0
  45. nab_python/_vendor/packaging/requirements.py +132 -0
  46. nab_python/_vendor/packaging/specifiers.py +1141 -0
  47. nab_python/_vendor/packaging/tags.py +929 -0
  48. nab_python/_vendor/packaging/utils.py +296 -0
  49. nab_python/_vendor/packaging/version.py +1230 -0
  50. nab_python/build_backend.py +184 -0
  51. nab_python/config.py +805 -0
  52. nab_python/download.py +170 -0
  53. nab_python/fetch.py +827 -0
  54. nab_python/lockfile.py +238 -0
  55. nab_python/metadata.py +145 -0
  56. nab_python/provider.py +1235 -0
  57. nab_python/py.typed +0 -0
  58. nab_python/requirements_file.py +180 -0
  59. nab_python/resolve.py +497 -0
  60. nab_python/universal/__init__.py +1 -0
  61. nab_python/universal/matrix.py +235 -0
  62. nab_python/universal/provider.py +214 -0
  63. nab_python/universal/reresolve.py +310 -0
  64. nab_python/universal/resolve.py +508 -0
  65. nab_python/universal/validate.py +439 -0
  66. nab_python/universal/wheel_selection.py +327 -0
  67. nab_python/workspace.py +214 -0
  68. nab_python-0.0.1.dist-info/METADATA +49 -0
  69. nab_python-0.0.1.dist-info/RECORD +71 -0
  70. nab_python-0.0.1.dist-info/WHEEL +4 -0
  71. nab_python-0.0.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,132 @@
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+ from __future__ import annotations
5
+
6
+ from typing import TYPE_CHECKING
7
+
8
+ from ._parser import parse_requirement as _parse_requirement
9
+ from ._tokenizer import ParserSyntaxError
10
+ from .markers import Marker, _normalize_extra_values
11
+ from .specifiers import SpecifierSet
12
+ from .utils import canonicalize_name
13
+
14
+ if TYPE_CHECKING:
15
+ from collections.abc import Iterator
16
+
17
+ __all__ = [
18
+ "InvalidRequirement",
19
+ "Requirement",
20
+ ]
21
+
22
+
23
+ def __dir__() -> list[str]:
24
+ return __all__
25
+
26
+
27
+ class InvalidRequirement(ValueError):
28
+ """
29
+ An invalid requirement was found, users should refer to PEP 508.
30
+ """
31
+
32
+
33
+ class Requirement:
34
+ """Parse a requirement.
35
+
36
+ Parse a given requirement string into its parts, such as name, specifier,
37
+ URL, and extras. Raises InvalidRequirement on a badly-formed requirement
38
+ string.
39
+
40
+ Instances are safe to serialize with :mod:`pickle`. They use a stable
41
+ format so the same pickle can be loaded in future packaging releases.
42
+
43
+ .. versionchanged:: 26.2
44
+
45
+ Added a stable pickle format. Pickles created with packaging 26.2+ can
46
+ be unpickled with future releases. Backward compatibility with pickles
47
+ from packaging < 26.2 is supported but may be removed in a future
48
+ release.
49
+ """
50
+
51
+ # TODO: Can we test whether something is contained within a requirement?
52
+ # If so how do we do that? Do we need to test against the _name_ of
53
+ # the thing as well as the version? What about the markers?
54
+ # TODO: Can we normalize the name and extra name?
55
+
56
+ def __init__(self, requirement_string: str) -> None:
57
+ try:
58
+ parsed = _parse_requirement(requirement_string)
59
+ except ParserSyntaxError as e:
60
+ raise InvalidRequirement(str(e)) from e
61
+
62
+ self.name: str = parsed.name
63
+ self.url: str | None = parsed.url or None
64
+ self.extras: set[str] = set(parsed.extras or [])
65
+ self.specifier: SpecifierSet = SpecifierSet(parsed.specifier)
66
+ self.marker: Marker | None = None
67
+ if parsed.marker is not None:
68
+ self.marker = Marker.__new__(Marker)
69
+ self.marker._markers = _normalize_extra_values(parsed.marker)
70
+
71
+ def _iter_parts(self, name: str) -> Iterator[str]:
72
+ yield name
73
+
74
+ if self.extras:
75
+ formatted_extras = ",".join(sorted(self.extras))
76
+ yield f"[{formatted_extras}]"
77
+
78
+ if self.specifier:
79
+ yield str(self.specifier)
80
+
81
+ if self.url:
82
+ yield f" @ {self.url}"
83
+ if self.marker:
84
+ yield " "
85
+
86
+ if self.marker:
87
+ yield f"; {self.marker}"
88
+
89
+ def __getstate__(self) -> str:
90
+ # Return the requirement string for compactness and stability.
91
+ # Re-parsed on load to reconstruct all fields.
92
+ return str(self)
93
+
94
+ def __setstate__(self, state: object) -> None:
95
+ if isinstance(state, str):
96
+ # New format (26.2+): just the requirement string.
97
+ try:
98
+ tmp = Requirement(state)
99
+ except InvalidRequirement as exc:
100
+ raise TypeError(f"Cannot restore Requirement from {state!r}") from exc
101
+ self.name = tmp.name
102
+ self.url = tmp.url
103
+ self.extras = tmp.extras
104
+ self.specifier = tmp.specifier
105
+ self.marker = tmp.marker
106
+ return
107
+ if isinstance(state, dict):
108
+ # Old format (packaging <= 26.1, no __slots__): plain __dict__.
109
+ self.__dict__.update(state)
110
+ return
111
+ raise TypeError(f"Cannot restore Requirement from {state!r}")
112
+
113
+ def __str__(self) -> str:
114
+ return "".join(self._iter_parts(self.name))
115
+
116
+ def __repr__(self) -> str:
117
+ return f"<{self.__class__.__name__}({str(self)!r})>"
118
+
119
+ def __hash__(self) -> int:
120
+ return hash(tuple(self._iter_parts(canonicalize_name(self.name))))
121
+
122
+ def __eq__(self, other: object) -> bool:
123
+ if not isinstance(other, Requirement):
124
+ return NotImplemented
125
+
126
+ return (
127
+ canonicalize_name(self.name) == canonicalize_name(other.name)
128
+ and self.extras == other.extras
129
+ and self.specifier == other.specifier
130
+ and self.url == other.url
131
+ and self.marker == other.marker
132
+ )