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
24 changes: 8 additions & 16 deletions pyodide_build/uv_helper.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import functools
import os
import contextlib
import shutil


@functools.cache
def find_uv_bin() -> str | None:
"""
Check if the uv executable is available.

If the uv executable is available, return the path to the executable.
Return the path to the uv executable, or None if not found.
Prefers the uv Python package over a PATH lookup.
Otherwise, return None.
"""
try:
import uv
with contextlib.suppress(ImportError, FileNotFoundError):
from uv import find_uv_bin as _find_uv_bin

return uv.find_uv_bin()
except (ModuleNotFoundError, FileNotFoundError):
return shutil.which("uv")
return _find_uv_bin()

return None
return shutil.which("uv")


def should_use_uv() -> bool:
# UV environ is set to the uv executable path when the script is called with the uv executable.
uv_environ = os.environ.get("UV")
# double check by comparing the uv executable path with the one found by the uv package.
return uv_environ and uv_environ == find_uv_bin()
return find_uv_bin() is not None
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ authors = [{name = "Pyodide developers"}]
description = '"Tools for building Pyodide"'
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Operating System :: OS Independent",
]
license = {text = "MPL-2.0"}
license = "MPL-2.0"
license-files = ["LICENSE"]
requires-python = ">=3.12"
dependencies = [
"build>=1.4,<1.6,!=1.4.4",
"build>=1.4,<1.6,!=1.4.4", # keep in sync with uv extra
"pyodide-cli>=0.4.1",
"pyodide-lock~=0.1.0",
"auditwheel-emscripten~=0.2.0",
Expand Down Expand Up @@ -59,7 +59,7 @@ resolve = [
"unearth~=0.6",
]
uv = [
"build[uv]~=1.4.0",
"build[uv]>=1.4,<1.6,!=1.4.4",
]

[dependency-groups]
Expand Down
Loading