Skip to content

Commit

Permalink
[tasks] add download link to update python (#31831)
Browse files Browse the repository at this point in the history
  • Loading branch information
pducolin authored Dec 10, 2024
1 parent 6615d8d commit 27d7ef8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 12 additions & 0 deletions tasks/libs/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,3 +661,15 @@ def agent_working_directory():
from tasks.libs.common.worktree import LOCAL_DIRECTORY, WORKTREE_DIRECTORY, is_worktree

return WORKTREE_DIRECTORY if is_worktree() else LOCAL_DIRECTORY


def is_macos():
return sys.platform == 'darwin'


def is_linux():
return sys.platform.startswith('linux')


def is_windows():
return sys.platform == 'win32'
15 changes: 10 additions & 5 deletions tasks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from tasks.libs.common.color import Color, color_message
from tasks.libs.common.git import get_default_branch
from tasks.libs.common.status import Status
from tasks.libs.common.utils import running_in_pyapp
from tasks.libs.common.utils import is_linux, is_windows, running_in_pyapp

if TYPE_CHECKING:
from collections.abc import Generator
Expand Down Expand Up @@ -145,10 +145,15 @@ def check_python_version(_ctx) -> SetupResult:
status = Status.OK
if tuple(sys.version_info)[:2] != tuple(int(d) for d in expected_version.split(".")):
status = Status.FAIL
message = (
f"Python version is {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}. "
"Please update your environment: https://datadoghq.dev/datadog-agent/setup/#python-dependencies"
)
install_message = f"Please install Python {expected_version} with 'brew install python@{expected_version}'"
if is_windows():
install_message = f"Please install Python {expected_version} from https://www.python.org/downloads/windows/"
elif is_linux():
install_message = (
f"Please install Python {expected_version} with 'sudo apt-get install python{expected_version}-dev'"
)

message = f"Python version out of date, current is {sys.version_info[0]}.{sys.version_info[1]} while expected is {expected_version}.\n{install_message}"

return SetupResult("Check Python version", status, message)

Expand Down

0 comments on commit 27d7ef8

Please sign in to comment.