metaflow icon indicating copy to clipboard operation
metaflow copied to clipboard

uv support for multiple platforms/architecture

Open RodCor opened this issue 2 months ago • 3 comments

Nowadays is only hardcoded to x86_64

# TODO: support version/platform/architecture selection.
UV_URL = "https://github.com/astral-sh/uv/releases/download/0.6.11/uv-x86_64-unknown-linux-gnu.tar.gz"

It should detect the uv version installed. I would think it's not something big to implement.

Proposed Fix

def get_uv_download_url(version=None):
    """
    Determine the appropriate UV download URL based on the current platform and architecture.
    
    Args:
        version: UV version to download (defaults to DEFAULT_UV_VERSION or METAFLOW_UV_VERSION env var)
    
    Returns:
        str: Download URL for the appropriate UV binary
    """
    if version is None:
        version = os.environ.get("METAFLOW_UV_VERSION", DEFAULT_UV_VERSION)
    
    system = platform.system().lower()
    machine = platform.machine().lower()
    
    # Map Python's platform identifiers to UV's target triples
    target_map = {
        "linux": {
            "x86_64": "x86_64-unknown-linux-gnu",
            "amd64": "x86_64-unknown-linux-gnu",
            "aarch64": "aarch64-unknown-linux-gnu",
            "arm64": "aarch64-unknown-linux-gnu",
            "armv7l": "armv7-unknown-linux-gnueabihf",
            "i686": "i686-unknown-linux-gnu",
            "i386": "i686-unknown-linux-gnu",
            "ppc64le": "powerpc64le-unknown-linux-gnu",
            "s390x": "s390x-unknown-linux-gnu",
        },
        "darwin": {
            "x86_64": "x86_64-apple-darwin",
            "amd64": "x86_64-apple-darwin",
            "arm64": "aarch64-apple-darwin",
            "aarch64": "aarch64-apple-darwin",
        },
        "windows": {
            "x86_64": "x86_64-pc-windows-msvc",
            "amd64": "x86_64-pc-windows-msvc",
            "i686": "i686-pc-windows-msvc",
            "i386": "i686-pc-windows-msvc",
        },
    }
    
    if system not in target_map:
        raise RuntimeError(
            f"Unsupported operating system: {system}. "
            f"Supported systems are: {', '.join(target_map.keys())}"
        )
    
    if machine not in target_map[system]:
        raise RuntimeError(
            f"Unsupported architecture '{machine}' for {system}. "
            f"Supported architectures are: {', '.join(target_map[system].keys())}"
        )
    
    target = target_map[system][machine]
    
    # Windows uses .zip, others use .tar.gz
    extension = "zip" if system == "windows" else "tar.gz"
    
    url = f"https://github.com/astral-sh/uv/releases/download/{version}/uv-{target}.{extension}"
    
    return url


UV_URL = get_uv_download_url()

RodCor avatar Oct 17 '25 15:10 RodCor

Can i work on this

Kamalesh-Seervi avatar Nov 04 '25 19:11 Kamalesh-Seervi

sure - although the code snippet posted can be simplified significantly. windows and darwin based remote compute options are quite rare and not well tested.

savingoyal avatar Nov 18 '25 19:11 savingoyal

yeh we can optimize it better if not tested well do we need this feature ?

Kamalesh-Seervi avatar Nov 21 '25 06:11 Kamalesh-Seervi