Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/taskgraph/run-task/run-task
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,23 @@ def _display_python_version():
b"setup", b"Python version: %s\n" % platform.python_version().encode("utf-8")
)

def _display_subprocess_python_version():

python_versions = ["python","python3"]

for python_executable in python_versions:
try:
version = subprocess.check_output(
[python_executable, "-c", "import platform; print(platform.python_version())"],
).strip()

print_line(
b"setup", b"Subprocess %s version: %s\n" % (python_executable.encode(), version)
)

except FileNotFoundError:
pass


def main(args):
task_workdir = os.environ["TASK_WORKDIR"] = os.getcwd()
Expand All @@ -1045,6 +1062,7 @@ def main(args):
b"Invoked by command: %s\n" % " ".join(args).encode("utf-8"),
)
_display_python_version()
_display_subprocess_python_version()
running_as_root = IS_POSIX and os.getuid() == 0

# Arguments up to '--' are ours. After are for the main task
Expand Down
12 changes: 12 additions & 0 deletions test/test_scripts_run_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,18 @@ def test_display_python_version_should_output_python_versions(run_task_mod, caps
assert ("Python version: 3." in output) or ("Python version: 2." in output) is True


def test_display_subprocess_python_version_should_output_python_versions_title(
run_task_mod, capsys
):
run_task_mod._display_subprocess_python_version()

assert (
("Subprocess python3 version:" in capsys.readouterr().out)
or ("Subprocess python2 version:" in capsys.readouterr().out)
or ("Subprocess python version:" in capsys.readouterr().out) is True
)


@pytest.fixture
def run_main(tmp_path, mocker, mock_stdin, run_task_mod):
base_args = [
Expand Down
Loading