Skip to content

Function to infer the uv version #1155

Description

@nathanjmcdougall

Toward #1130 in src\usethis\_integrations\backend\uv\version.py

Draft:

import json

from usethis._integrations.backend.uv.call import call_uv_subprocess
from usethis._integrations.backend.uv.errors import UVSubprocessFailedError

FALLBACK_UV_VERSION = "0.9.9"


def get_uv_version() -> str:
    try:
        json_str = call_uv_subprocess(
            ["self", "version", "--output-format=json"],
            change_toml=True,
        )
    except UVSubprocessFailedError:
        return FALLBACK_UV_VERSION


    json_dict = json.loads(json_str)
    return json_dict.get("version", FALLBACK_UV_VERSION)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions