python-discovery 1.9.2__py3-none-any.whl → 1.9.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.
@@ -496,13 +496,14 @@ def path_exe_finder(
496
496
  direct = f"{direct}.exe"
497
497
 
498
498
  def path_exes(path: Path) -> Generator[tuple[Path, bool], None, None]:
499
+ # an empty spec (enumerating everything) would make the direct path the PATH directory itself
499
500
  direct_path = path / direct
500
- if direct_path.exists():
501
+ if direct_path.is_file():
501
502
  yield direct_path, impl_must_match
502
503
 
503
504
  for exe in path.iterdir():
504
- if pat.fullmatch(exe.name):
505
- yield exe.absolute(), impl_must_match
505
+ if (match := pat.fullmatch(exe.name)) and exe.is_file():
506
+ yield exe.absolute(), impl_must_match or match["impl"].lower() == "python"
506
507
 
507
508
  return path_exes
508
509
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import contextlib
6
5
  import pathlib
7
6
  import re
8
7
  from typing import Final
@@ -235,27 +234,31 @@ class PythonSpec:
235
234
  if not components:
236
235
  return True
237
236
 
238
- version_str = ".".join(str(part) for part in components)
239
237
  if spec.version_specifier is None:
240
238
  return True
241
- with contextlib.suppress(InvalidVersion):
242
- Version.from_string(version_str)
243
- for item in spec.version_specifier:
244
- required_precision = self._get_required_precision(item)
245
- if required_precision is None or len(components) < required_precision:
246
- continue
247
- if not item.contains(version_str):
248
- return False
239
+ for item in spec.version_specifier:
240
+ required_precision = self._get_required_precision(item)
241
+ if required_precision is None or len(components) < required_precision:
242
+ continue
243
+ # Registry versions omit prerelease status, so a matching release still needs interrogation.
244
+ if (
245
+ (version := item.version) is not None
246
+ and version.pre_type is not None
247
+ and tuple(components[:required_precision]) == version.release[:required_precision]
248
+ ):
249
+ continue
250
+ # compare at the precision the specifier was written with, as PythonInfo.satisfies does
251
+ if not item.contains(".".join(str(part) for part in components[:required_precision])):
252
+ return False
249
253
  return True
250
254
 
251
255
  @staticmethod
252
256
  def _get_required_precision(item: SimpleSpecifier) -> int | None:
253
- """Get the required precision for a specifier item."""
254
257
  if item.version is None:
255
258
  return None
256
- with contextlib.suppress(AttributeError, ValueError):
257
- return len(item.version.release)
258
- return None
259
+ if item.wildcard_precision is not None:
260
+ return item.wildcard_precision
261
+ return re.split(r"a|b|rc", item.version_str, maxsplit=1)[0].count(".") + 1
259
262
 
260
263
  def satisfies(self, spec: PythonSpec) -> bool: # ruff:ignore[too-many-return-statements]
261
264
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-discovery
3
- Version: 1.9.2
3
+ Version: 1.9.5
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,17 +2,17 @@ python_discovery/__init__.py,sha256=BV4pKMWDAK_3pU8o2hYvtL30WKs_wTzIBRuFV7nUaug,
2
2
  python_discovery/_cache.py,sha256=HVGs7H0p-iee2TESXUUn-L5Sv4Sdb0b3r-1JQdGNchQ,8446
3
3
  python_discovery/_cached_py_info.py,sha256=F9lKdba0pxJB6Pczuh-MtVdLrklvqrKwzLovnPijJd8,17117
4
4
  python_discovery/_compat.py,sha256=iqxGuhK9rPaiui80G1H1KrweoMJ16gyLYEmUrSXrp5c,709
5
- python_discovery/_discovery.py,sha256=VXw4ZTSM0GIUOIPEDFcOrurjqRF8HC6eRxB36PNB8_o,25030
5
+ python_discovery/_discovery.py,sha256=sFG0IOkhHU4q1uAPo0Bcejz_gpN6k4BFnbdmjZqX9iA,25199
6
6
  python_discovery/_py_info.py,sha256=jci7XqbmcPsfZitkLBIMYbC9iDz48sXky1or-q8L6qo,28158
7
7
  python_discovery/_py_info_collect.py,sha256=DEUo5hNXwjxchbYppyQEuNZ627jCukB9XmtCdIIRN7Y,17928
8
- python_discovery/_py_spec.py,sha256=s76yM2zbrKdvwhaDlPyUo6ERKkn2MldRNydPZucNvOM,12154
8
+ python_discovery/_py_spec.py,sha256=s1XhGhzlo7947SdHYMzSS99OGUeCOEEQZXaZQc-eh0I,12452
9
9
  python_discovery/_specifier.py,sha256=bv2o_ft2Ak2tKjQblncWjKgCW3Hg4RocTebz9Jyovac,10690
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/_cancel_io.py,sha256=aL1FxCqv01fYb56SI_TvFyRDcb_zpCcU6oMj330IRio,1689
13
13
  python_discovery/_windows/_pep514.py,sha256=VLXB7LXaKfqOKRz2IklZOf4tW-NE0F9cEKRQYV4eyRM,8279
14
14
  python_discovery/_windows/_propose.py,sha256=EE-N-BiNgrFU9mQ34SkoF5gRaNjtspghssQxT9uRQi0,1756
15
- python_discovery-1.9.2.dist-info/METADATA,sha256=hjQSjjgj_wiXHip7765qcZeoAjY9wjh30gxiYgv5lPw,4235
16
- python_discovery-1.9.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
17
- python_discovery-1.9.2.dist-info/licenses/LICENSE,sha256=kOJeH68qSq6o2V7o5_VziwUqGswMnFgGgQH5Mahr1Yg,1023
18
- python_discovery-1.9.2.dist-info/RECORD,,
15
+ python_discovery-1.9.5.dist-info/METADATA,sha256=5dR6ijups7CknfKtJkBKfAIPNw5f3lQwHUHcAvKaR4c,4235
16
+ python_discovery-1.9.5.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
17
+ python_discovery-1.9.5.dist-info/licenses/LICENSE,sha256=kOJeH68qSq6o2V7o5_VziwUqGswMnFgGgQH5Mahr1Yg,1023
18
+ python_discovery-1.9.5.dist-info/RECORD,,