Skip to content

Commit ab5ea45

Browse files
authored
Show host python under core section as constant (#2644)
1 parent 31ad830 commit ab5ea45

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/changelog/2630.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The core tox configuration now contains ``host_python`` key showing the host python executable path -
2+
by :user:`gaborbernat`.

src/tox/config/sets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import sys
34
from abc import ABC, abstractmethod
45
from pathlib import Path
56
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
202203
default=lambda conf, _: cast(Path, self["work_dir"]) / ".tmp", # noqa: U100, U101
203204
desc="a folder for temporary files (is not cleaned at start)",
204205
)
206+
self.add_constant("host_python", "the host python executable path", sys.executable)
205207

206208
def _on_duplicate_conf(self, key: str, definition: ConfigDefinition[V]) -> None: # noqa: U100
207209
pass # core definitions may be defined multiple times as long as all their options match, first defined wins

tests/session/cmd/test_show_config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,10 @@ def test_show_config_timeout_custom(tox_project: ToxProjectCreator) -> None:
219219
def test_show_config_help(tox_project: ToxProjectCreator) -> None:
220220
outcome = tox_project({"tox.ini": ""}).run("c", "-h")
221221
outcome.assert_success()
222+
223+
224+
def test_show_config_core_host_python(tox_project: ToxProjectCreator) -> None:
225+
project = tox_project({"tox.ini": ""})
226+
outcome = project.run("c", "--core", "-e", "py", "-k", "host_python")
227+
outcome.assert_success()
228+
assert f"host_python = {sys.executable}" in outcome.out

0 commit comments

Comments
 (0)