Skip to content

Commit

Permalink
fix(self-update): prevent unsupported systems trying to upgrade to uv…
Browse files Browse the repository at this point in the history
…x 2.x
  • Loading branch information
robinvandernoord committed Apr 26, 2024
1 parent dce1cbb commit c3862f9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/uvx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import functools
import os
import platform
import subprocess # nosec
import sys
import typing
Expand Down Expand Up @@ -192,6 +193,19 @@ def uninject(
)


UVX2_PLATFORMS = {"linux"}
UVX2_ARCH = {"x86_64", "aarch64"}


def system_supports_uvx2() -> bool:
return sys.platform in UVX2_PLATFORMS and platform.machine() in UVX2_ARCH


def _uvx_upgrade_spec():
# uvx 2.x should only be used on supported platforms.
return "uvx" if system_supports_uvx2() else "uvx<2"


def _self_update_via_cmd(pip_ish: BoundCommand, with_uv: bool):
old = {}
new = {}
Expand All @@ -200,7 +214,7 @@ def _self_update_via_cmd(pip_ish: BoundCommand, with_uv: bool):

old["uvx"] = _get_package_version("uvx", pip_ish["freeze"], default="unknown")

cmd = pip_ish["install", "--upgrade", "uvx"]
cmd = pip_ish["install", "--upgrade", _uvx_upgrade_spec()]
if with_uv:
cmd = cmd["uv"]

Expand Down

0 comments on commit c3862f9

Please sign in to comment.