Skip to content
Merged
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
19 changes: 17 additions & 2 deletions src/taskgraph/run-task/run-task
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,25 @@ def install_pip_requirements(repositories):
run_required_command(b"pip-install", cmd)


def _display_python_version():
def _display_python_versions():
print_line(
b"setup", b"Python version: %s\n" % platform.python_version().encode("utf-8")
)

print_line(b"setup", b"Subprocess python version: " + b"\n")

try:
subprocess.run(["uv", "python", "list","--no-cache","--only-installed"], check=True)

except (FileNotFoundError, subprocess.CalledProcessError):

python_versions = ["python","python3"]

for python_executable in python_versions:
try:
subprocess.run([python_executable, "-c", "import platform; print(platform.python_version())"], check=True)
except FileNotFoundError:
pass


def main(args):
Expand All @@ -1044,7 +1059,7 @@ def main(args):
b"setup",
b"Invoked by command: %s\n" % " ".join(args).encode("utf-8"),
)
_display_python_version()
_display_python_versions()
running_as_root = IS_POSIX and os.getuid() == 0

# Arguments up to '--' are ours. After are for the main task
Expand Down
9 changes: 6 additions & 3 deletions test/test_scripts_run_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,19 @@ def test_git_checkout_with_commit(
def test_display_python_version_should_output_python_versions_title(
run_task_mod, capsys
):
run_task_mod._display_python_version()
run_task_mod._display_python_versions()

assert ("Python version:" in capsys.readouterr().out) is True
output = capsys.readouterr().out
assert ("Python version:" in output) is True
assert "Subprocess" in output and "version:" in output


def test_display_python_version_should_output_python_versions(run_task_mod, capsys):
run_task_mod._display_python_version()
run_task_mod._display_python_versions()

output = capsys.readouterr().out
assert ("Python version: 3." in output) or ("Python version: 2." in output) is True
assert "Subprocess" in output and "version:" in output


@pytest.fixture
Expand Down
Loading