python-discovery 1.6.5__py3-none-any.whl → 1.6.6__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.
@@ -158,7 +158,8 @@ def _check_exe(path: str, tested_exes: set[str]) -> str | None:
158
158
  if exe_id in tested_exes:
159
159
  return None
160
160
  tested_exes.add(exe_id)
161
- return str(Path(path).absolute())
161
+ # unlike Path.absolute(), abspath collapses "..", which PythonInfo._satisfies_path relies on
162
+ return os.path.abspath(path)
162
163
 
163
164
 
164
165
  def _is_new_exe(exe_raw: str, tested_exes: set[str]) -> bool:
@@ -295,7 +295,8 @@ class PythonInfo: # ruff:ignore[too-many-public-methods]
295
295
  return True
296
296
  version_info = self.version_info
297
297
  for specifier in spec.version_specifier:
298
- assert specifier.version is not None # ruff:ignore[assert]
298
+ if specifier.version is None: # a hand-built spec can carry an unparsable version, which matches nothing
299
+ return False
299
300
  numeric_version = specifier.version_str
300
301
  for prefix in ("rc", "b", "a"):
301
302
  if prefix in numeric_version:
@@ -104,6 +104,11 @@ def _parse_specifier(string_spec: str) -> PythonSpec | None:
104
104
  version_specifier = SpecifierSet.from_string(spec_text)
105
105
  except InvalidSpecifier: # pragma: no cover
106
106
  return None
107
+ # the set never raises: it keeps an unparsable version as None and drops items without an operator, so fall back
108
+ # to a literal path, like any other unrecognized spec, unless every item parsed into a usable version
109
+ items = [item for item in spec_text.split(",") if item.strip()]
110
+ if len(items) != len(version_specifier.specifiers) or any(spec.version is None for spec in version_specifier):
111
+ return None
107
112
  if impl in {"py", "python"}:
108
113
  impl = None
109
114
  if impl == "graalvm":
@@ -227,12 +227,10 @@ class SimpleSpecifier:
227
227
  return False
228
228
  if candidate < self.version:
229
229
  return False
230
- if len(self.version.release) >= 2: # ruff:ignore[magic-value-comparison] # pragma: no branch # SimpleVersion always has 3-part release
231
- upper_parts = list(self.version.release[:-1])
232
- upper_parts[-1] += 1
233
- upper = SimpleVersion.from_string(".".join(str(p) for p in upper_parts))
234
- return candidate < upper
235
- return True # pragma: no cover
230
+ # ~=X.Y is >=X.Y, ==X.*: compare all but the last part the spec wrote (release is padded to three).
231
+ # A bare ~=X still compares its one part, so it stays ==X.*.
232
+ prefix = max(self.version_str.count("."), 1)
233
+ return candidate.release[:prefix] == self.version.release[:prefix]
236
234
 
237
235
  def __eq__(self, other: object) -> bool:
238
236
  if not isinstance(other, SimpleSpecifier):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-discovery
3
- Version: 1.6.5
3
+ Version: 1.6.6
4
4
  Import-Name: python_discovery
5
5
  Summary: Python interpreter discovery
6
6
  Project-URL: Changelog, https://github.com/tox-dev/python-discovery/blob/main/docs/changelog.rst
@@ -2,16 +2,16 @@ python_discovery/__init__.py,sha256=Hi4j3pMvC8Fo8KoNL-wOHsPSCUHwY4c0qvv5sjnFzME,
2
2
  python_discovery/_cache.py,sha256=svmG2GzUQzd2xTjAbm2eX1CKxxGAglfv4kxaPuxwPIA,5147
3
3
  python_discovery/_cached_py_info.py,sha256=15P5_TODxkZCkNfD2Uk5dtPxGf0Nea_aWm2N7uY9zbY,12059
4
4
  python_discovery/_compat.py,sha256=iqxGuhK9rPaiui80G1H1KrweoMJ16gyLYEmUrSXrp5c,709
5
- python_discovery/_discovery.py,sha256=BDHC1XEx0XNStEIbXjujpHHm0nkBpe26bl26YVHSWhM,22488
6
- python_discovery/_py_info.py,sha256=rRyixfRnqyrmudr7SSSKLxKfsCjdfSezH30YE6n773U,26672
5
+ python_discovery/_discovery.py,sha256=E5b-Sb6jLq_5hVOK0LZwKwvUxMNVsH9UPmf0dCpzZnA,22580
6
+ python_discovery/_py_info.py,sha256=SDBYXdoL3aXTfLOgHXrElXK_Og5cJOeJPK7j3rNvTu8,26747
7
7
  python_discovery/_py_info_collect.py,sha256=3PNlySbxNSHDjBw8KJ_olVpOXww1qhGdY28YoLfF0Z8,16160
8
- python_discovery/_py_spec.py,sha256=1L7uVqpLdTVvHX6ZcXiUICFAfnOcJaThfdCGIntp7l4,11073
9
- python_discovery/_specifier.py,sha256=o7MHb0z_mFSLz9gXqMwJoNkHYjgi2biq3Ibvd0_slvc,10457
8
+ python_discovery/_py_spec.py,sha256=uN6PftKwk8cJnnbav5kXpbnQQYQ56LZ828KLp04YGKU,11499
9
+ python_discovery/_specifier.py,sha256=9sMnJs7FTfIIduTCKKTA7Lk7onARqwkG_zzFIqgj0xs,10364
10
10
  python_discovery/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  python_discovery/_windows/__init__.py,sha256=qthcyGh36b3WkeSbZ4ECRRYLbCOCaQu5X_DRZ98tXfk,315
12
12
  python_discovery/_windows/_pep514.py,sha256=Vhxe-3hETFIXQrekLqOHmzG5eq5moeR8b0dCS80zbBg,8026
13
13
  python_discovery/_windows/_propose.py,sha256=EE-N-BiNgrFU9mQ34SkoF5gRaNjtspghssQxT9uRQi0,1756
14
- python_discovery-1.6.5.dist-info/METADATA,sha256=78OyeINSSee7ey10RdKTp08DQSfDYouEGKv_4ncAbg0,3937
15
- python_discovery-1.6.5.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
16
- python_discovery-1.6.5.dist-info/licenses/LICENSE,sha256=kOJeH68qSq6o2V7o5_VziwUqGswMnFgGgQH5Mahr1Yg,1023
17
- python_discovery-1.6.5.dist-info/RECORD,,
14
+ python_discovery-1.6.6.dist-info/METADATA,sha256=ALuIM6ZR6RkPYhHcBUyz9t1OiidUMOiOU1eXi0_R284,3937
15
+ python_discovery-1.6.6.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
16
+ python_discovery-1.6.6.dist-info/licenses/LICENSE,sha256=kOJeH68qSq6o2V7o5_VziwUqGswMnFgGgQH5Mahr1Yg,1023
17
+ python_discovery-1.6.6.dist-info/RECORD,,