diff --git a/docs/changelog/2630.bugfix.rst b/docs/changelog/2630.bugfix.rst new file mode 100644 index 000000000..a825a5da4 --- /dev/null +++ b/docs/changelog/2630.bugfix.rst @@ -0,0 +1,2 @@ +The core tox configuration now contains ``host_python`` key showing the host python executable path - +by :user:`gaborbernat`. diff --git a/src/tox/config/sets.py b/src/tox/config/sets.py index 0315369a7..d5e90c1f5 100644 --- a/src/tox/config/sets.py +++ b/src/tox/config/sets.py @@ -1,5 +1,6 @@ from __future__ import annotations +import sys from abc import ABC, abstractmethod from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Iterator, Mapping, Sequence, TypeVar, cast @@ -202,6 +203,7 @@ def work_dir_builder(conf: Config, env_name: str | None) -> Path: # noqa: U100 default=lambda conf, _: cast(Path, self["work_dir"]) / ".tmp", # noqa: U100, U101 desc="a folder for temporary files (is not cleaned at start)", ) + self.add_constant("host_python", "the host python executable path", sys.executable) def _on_duplicate_conf(self, key: str, definition: ConfigDefinition[V]) -> None: # noqa: U100 pass # core definitions may be defined multiple times as long as all their options match, first defined wins diff --git a/tests/session/cmd/test_show_config.py b/tests/session/cmd/test_show_config.py index 0fa430291..eaddf7200 100644 --- a/tests/session/cmd/test_show_config.py +++ b/tests/session/cmd/test_show_config.py @@ -219,3 +219,10 @@ def test_show_config_timeout_custom(tox_project: ToxProjectCreator) -> None: def test_show_config_help(tox_project: ToxProjectCreator) -> None: outcome = tox_project({"tox.ini": ""}).run("c", "-h") outcome.assert_success() + + +def test_show_config_core_host_python(tox_project: ToxProjectCreator) -> None: + project = tox_project({"tox.ini": ""}) + outcome = project.run("c", "--core", "-e", "py", "-k", "host_python") + outcome.assert_success() + assert f"host_python = {sys.executable}" in outcome.out