python-discovery 1.7.0__tar.gz → 1.9.0__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.
- {python_discovery-1.7.0 → python_discovery-1.9.0}/PKG-INFO +1 -1
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/changelog.rst +28 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/how-to/standalone-usage.rst +6 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/pyproject.toml +1 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/__init__.py +2 -1
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_py_info.py +17 -1
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_py_info_collect.py +24 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/py_info/test_py_info.py +49 -2
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/FUNDING.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/SECURITY.md +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/THREAT_MODEL.md +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/dependabot.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/release.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/check.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/codeql.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/news.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/prepare-release.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/release.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/upgrade-release-tools.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.gitignore +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.pre-commit-config.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.readthedocs.yaml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/.readthedocs.yml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/CODE_OF_CONDUCT.md +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/LICENSE +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/README.md +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/_static/custom.css +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/_static/github.svg +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/_static/logo.svg +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/changelog/template.jinja2 +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/conf.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/contributing.rst +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/explanation.rst +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/index.rst +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/reference/api.rst +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/reference/environment-variables.rst +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/docs/tutorial/getting-started.rst +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/pylock.toml +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_cache.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_cached_py_info.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_compat.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_discovery.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_py_spec.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_specifier.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_windows/__init__.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_windows/_pep514.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/_windows/_propose.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/src/python_discovery/py.typed +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tasks/old_target_check.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tasks/old_target_check.sh +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/conftest.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/py_info/test_py_info_exe_based_of.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_cache.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_cache_recovery.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_cached_py_info.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_discovery.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_discovery_extra.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_iter_interpreters.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_py_info_collect.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_py_info_extra.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_py_spec.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_py_spec_extra.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_query_timeout.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/test_specifier.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/windows/conftest.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/windows/test_windows.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/windows/test_windows_pep514.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tests/windows/winreg_mock_values.py +0 -0
- {python_discovery-1.7.0 → python_discovery-1.9.0}/tox.toml +0 -0
|
@@ -6,6 +6,34 @@
|
|
|
6
6
|
|
|
7
7
|
.. towncrier release notes start
|
|
8
8
|
|
|
9
|
+
.. _release-1-9-0:
|
|
10
|
+
|
|
11
|
+
*********************
|
|
12
|
+
v1.9.0 (2026-10-30)
|
|
13
|
+
*********************
|
|
14
|
+
|
|
15
|
+
.. _release-1-9-0-added:
|
|
16
|
+
|
|
17
|
+
Added
|
|
18
|
+
-----
|
|
19
|
+
|
|
20
|
+
- Expose the 11 marker keys through ``MarkerEnvironment`` for callers that type-check ``PythonInfo.marker_environment``
|
|
21
|
+
(:pr:`179`) by :user:`gaborbernat`.
|
|
22
|
+
|
|
23
|
+
.. _release-1-8-0:
|
|
24
|
+
|
|
25
|
+
*********************
|
|
26
|
+
v1.8.0 (2026-10-30)
|
|
27
|
+
*********************
|
|
28
|
+
|
|
29
|
+
.. _release-1-8-0-added:
|
|
30
|
+
|
|
31
|
+
Added
|
|
32
|
+
-----
|
|
33
|
+
|
|
34
|
+
- Expose the selected interpreter's dependency marker values as ``PythonInfo.marker_environment`` (:pr:`178`) by
|
|
35
|
+
:user:`gaborbernat`.
|
|
36
|
+
|
|
9
37
|
.. _release-1-7-0:
|
|
10
38
|
|
|
11
39
|
*********************
|
|
@@ -153,6 +153,7 @@ Once you have a :class:`~python_discovery.PythonInfo`, you can inspect everythin
|
|
|
153
153
|
+platform: str
|
|
154
154
|
+sysconfig_vars: dict
|
|
155
155
|
+sysconfig_paths: dict
|
|
156
|
+
+marker_environment: MarkerEnvironment
|
|
156
157
|
+machine: str
|
|
157
158
|
+free_threaded: bool
|
|
158
159
|
+debug_build: bool
|
|
@@ -178,6 +179,11 @@ Once you have a :class:`~python_discovery.PythonInfo`, you can inspect everythin
|
|
|
178
179
|
info.debug_build # True if this is a Py_DEBUG build.
|
|
179
180
|
info.sysconfig_vars # All sysconfig.get_config_vars() values.
|
|
180
181
|
info.sysconfig_paths # All sysconfig.get_paths() values.
|
|
182
|
+
info.marker_environment
|
|
183
|
+
|
|
184
|
+
Use ``marker_environment`` to evaluate :pep:`508` dependency markers for the discovered interpreter. The mapping
|
|
185
|
+
contains all standard marker keys, including its implementation version and operating system. The exported
|
|
186
|
+
``MarkerEnvironment`` type names those keys for type checkers.
|
|
181
187
|
|
|
182
188
|
Prefer :attr:`~python_discovery.PythonInfo.system_exe` over the raw
|
|
183
189
|
:attr:`~python_discovery.PythonInfo.system_executable` field it reads. The field is typed ``str | None`` because it
|
|
@@ -6,7 +6,7 @@ from importlib.metadata import version
|
|
|
6
6
|
|
|
7
7
|
from ._cache import ContentStore, DiskCache, PyInfoCache
|
|
8
8
|
from ._discovery import get_interpreter, iter_interpreters
|
|
9
|
-
from ._py_info import KNOWN_ARCHITECTURES, PythonInfo, normalize_isa
|
|
9
|
+
from ._py_info import KNOWN_ARCHITECTURES, MarkerEnvironment, PythonInfo, normalize_isa
|
|
10
10
|
from ._py_spec import KNOWN_IMPLEMENTATIONS, PythonSpec
|
|
11
11
|
from ._specifier import SimpleSpecifier, SimpleSpecifierSet, SimpleVersion
|
|
12
12
|
|
|
@@ -17,6 +17,7 @@ __all__ = [
|
|
|
17
17
|
"KNOWN_IMPLEMENTATIONS",
|
|
18
18
|
"ContentStore",
|
|
19
19
|
"DiskCache",
|
|
20
|
+
"MarkerEnvironment",
|
|
20
21
|
"PyInfoCache",
|
|
21
22
|
"PythonInfo",
|
|
22
23
|
"PythonSpec",
|
|
@@ -11,7 +11,7 @@ import sys
|
|
|
11
11
|
from collections import OrderedDict
|
|
12
12
|
from itertools import product
|
|
13
13
|
from string import digits
|
|
14
|
-
from typing import TYPE_CHECKING, ClassVar, Final, NamedTuple
|
|
14
|
+
from typing import TYPE_CHECKING, ClassVar, Final, NamedTuple, TypedDict
|
|
15
15
|
|
|
16
16
|
from ._py_info_collect import PythonInfoCollector
|
|
17
17
|
|
|
@@ -57,6 +57,7 @@ class PythonInfo: # ruff:ignore[too-many-public-methods]
|
|
|
57
57
|
os: str
|
|
58
58
|
free_threaded: bool
|
|
59
59
|
debug_build: bool
|
|
60
|
+
marker_environment: MarkerEnvironment
|
|
60
61
|
prefix: str | None
|
|
61
62
|
base_prefix: str | None
|
|
62
63
|
real_prefix: str | None
|
|
@@ -628,6 +629,20 @@ class PythonInfo: # ruff:ignore[too-many-public-methods]
|
|
|
628
629
|
yield upper
|
|
629
630
|
|
|
630
631
|
|
|
632
|
+
class MarkerEnvironment(TypedDict):
|
|
633
|
+
implementation_name: str
|
|
634
|
+
implementation_version: str
|
|
635
|
+
os_name: str
|
|
636
|
+
platform_machine: str
|
|
637
|
+
platform_release: str
|
|
638
|
+
platform_system: str
|
|
639
|
+
platform_version: str
|
|
640
|
+
python_full_version: str
|
|
641
|
+
platform_python_implementation: str
|
|
642
|
+
python_version: str
|
|
643
|
+
sys_platform: str
|
|
644
|
+
|
|
645
|
+
|
|
631
646
|
KNOWN_ARCHITECTURES: frozenset[str] = frozenset({
|
|
632
647
|
"arm64",
|
|
633
648
|
"loongarch64",
|
|
@@ -671,6 +686,7 @@ def normalize_isa(isa: str) -> str:
|
|
|
671
686
|
|
|
672
687
|
__all__ = [
|
|
673
688
|
"KNOWN_ARCHITECTURES",
|
|
689
|
+
"MarkerEnvironment",
|
|
674
690
|
"PythonInfo",
|
|
675
691
|
"VersionInfo",
|
|
676
692
|
"normalize_isa",
|
|
@@ -64,6 +64,30 @@ class PythonInfoCollector:
|
|
|
64
64
|
self.os = os.name
|
|
65
65
|
self.free_threaded = sysconfig.get_config_var("Py_GIL_DISABLED") == 1
|
|
66
66
|
self.debug_build = bool(sysconfig.get_config_var("Py_DEBUG"))
|
|
67
|
+
# Vermin checks the whole script against Python 2.7 despite the version gate above.
|
|
68
|
+
interpreter = getattr(sys, "implementation") # ruff:ignore[get-attr-with-constant]
|
|
69
|
+
interpreter_version = interpreter.version
|
|
70
|
+
marker_version = "{}.{}.{}{}".format(
|
|
71
|
+
interpreter_version.major,
|
|
72
|
+
interpreter_version.minor,
|
|
73
|
+
interpreter_version.micro,
|
|
74
|
+
"{}{}".format(interpreter_version.releaselevel[0], interpreter_version.serial)
|
|
75
|
+
if interpreter_version.releaselevel != "final"
|
|
76
|
+
else "",
|
|
77
|
+
)
|
|
78
|
+
self.marker_environment = {
|
|
79
|
+
"implementation_name": interpreter.name,
|
|
80
|
+
"implementation_version": marker_version,
|
|
81
|
+
"os_name": os.name,
|
|
82
|
+
"platform_machine": platform.machine(),
|
|
83
|
+
"platform_release": platform.release(),
|
|
84
|
+
"platform_system": platform.system(),
|
|
85
|
+
"platform_version": platform.version(),
|
|
86
|
+
"python_full_version": platform.python_version(),
|
|
87
|
+
"platform_python_implementation": platform.python_implementation(),
|
|
88
|
+
"python_version": ".".join(platform.python_version_tuple()[:2]),
|
|
89
|
+
"sys_platform": sys.platform,
|
|
90
|
+
}
|
|
67
91
|
|
|
68
92
|
def _init_prefixes(self):
|
|
69
93
|
def abs_path(value):
|
|
@@ -9,16 +9,18 @@ import sys
|
|
|
9
9
|
import sysconfig
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from textwrap import dedent
|
|
12
|
-
from typing import TYPE_CHECKING, NamedTuple
|
|
12
|
+
from typing import TYPE_CHECKING, Final, NamedTuple
|
|
13
13
|
|
|
14
14
|
import pytest
|
|
15
|
+
from packaging.markers import default_environment
|
|
15
16
|
from setuptools.dist import Distribution
|
|
16
17
|
|
|
17
|
-
from python_discovery import DiskCache, PythonInfo, PythonSpec
|
|
18
|
+
from python_discovery import DiskCache, MarkerEnvironment, PythonInfo, PythonSpec
|
|
18
19
|
from python_discovery import _cached_py_info as cached_py_info
|
|
19
20
|
from python_discovery._py_info import VersionInfo
|
|
20
21
|
|
|
21
22
|
if TYPE_CHECKING:
|
|
23
|
+
from packaging.markers import Environment
|
|
22
24
|
from pytest_mock import MockerFixture
|
|
23
25
|
|
|
24
26
|
IS_PYPY = PythonInfo.current_system().implementation == "PyPy"
|
|
@@ -492,6 +494,51 @@ def test_py_info_json_round_trip() -> None:
|
|
|
492
494
|
assert restored.machine == CURRENT.machine
|
|
493
495
|
|
|
494
496
|
|
|
497
|
+
def test_marker_environment_matches_target_interpreter() -> None:
|
|
498
|
+
info: Final[PythonInfo | None] = PythonInfo.from_exe(sys.executable, ignore_cache=True, resolve_to_host=False)
|
|
499
|
+
assert info is not None
|
|
500
|
+
assert info.marker_environment == default_environment()
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def test_marker_environment_type_has_standard_keys() -> None:
|
|
504
|
+
assert MarkerEnvironment.__required_keys__ == default_environment().keys()
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
def test_marker_environment_uses_target_platform(tmp_path: Path) -> None:
|
|
508
|
+
(tmp_path / "sitecustomize.py").write_text(
|
|
509
|
+
'import platform\nplatform.machine = lambda: "target-machine"\nplatform.release = lambda: "target-release"\n',
|
|
510
|
+
encoding="utf-8",
|
|
511
|
+
)
|
|
512
|
+
expected: Final[Environment] = default_environment()
|
|
513
|
+
assert expected["platform_machine"] != "target-machine"
|
|
514
|
+
assert expected["platform_release"] != "target-release"
|
|
515
|
+
info: Final[PythonInfo | None] = PythonInfo.from_exe(
|
|
516
|
+
sys.executable,
|
|
517
|
+
ignore_cache=True,
|
|
518
|
+
resolve_to_host=False,
|
|
519
|
+
env={**os.environ, "PYTHONPATH": str(tmp_path)},
|
|
520
|
+
)
|
|
521
|
+
assert info is not None
|
|
522
|
+
assert info.marker_environment == {
|
|
523
|
+
**expected,
|
|
524
|
+
"platform_machine": "target-machine",
|
|
525
|
+
"platform_release": "target-release",
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def test_marker_environment_survives_json_round_trip() -> None:
|
|
530
|
+
assert PythonInfo.from_json(CURRENT.to_json()).marker_environment == CURRENT.marker_environment
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def test_marker_environment_formats_prerelease(mocker: MockerFixture) -> None:
|
|
534
|
+
version: Final[VersionInfo] = VersionInfo(*sys.implementation.version)
|
|
535
|
+
mocker.patch.object(sys.implementation, "version", version._replace(releaselevel="candidate", serial=1))
|
|
536
|
+
|
|
537
|
+
assert PythonInfo().marker_environment["implementation_version"] == (
|
|
538
|
+
f"{version.major}.{version.minor}.{version.micro}c1"
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
|
|
495
542
|
@pytest.mark.parametrize(
|
|
496
543
|
("target_platform", "discovered_platforms", "expected_idx"),
|
|
497
544
|
[
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_discovery-1.7.0 → python_discovery-1.9.0}/.github/workflows/upgrade-release-tools.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_discovery-1.7.0 → python_discovery-1.9.0}/tests/py_info/test_py_info_exe_based_of.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|