Skip to content

Commit ff86029

Browse files
konstincthoyt
andauthored
Use shutil.which for the build backend (#10028)
From PEP 517: > All command-line scripts provided by the build-required packages must be present in the build environment’s PATH. For example, if a project declares a build-requirement on flit, then the following must work as a mechanism for running the flit command-line tool: > > ```python > import subprocess > import shutil > subprocess.check_call([shutil.which("flit"), ...]) > ``` Fixes #9991 --------- Co-authored-by: Charles Tapley Hoyt <[email protected]>
1 parent c4d0caa commit ff86029

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

python/uv/_build_backend.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ def warn_config_settings(config_settings: "dict | None" = None):
2626

2727
def call(args: "list[str]", config_settings: "dict | None" = None) -> str:
2828
"""Invoke a uv subprocess and return the filename from stdout."""
29+
import shutil
2930
import subprocess
3031
import sys
3132

32-
from ._find_uv import find_uv_bin
33-
3433
warn_config_settings(config_settings)
34+
# Unlike `find_uv_bin`, this mechanism must work according to PEP 517
35+
uv_bin = shutil.which("uv")
36+
if uv_bin is None:
37+
raise RuntimeError("uv was not properly installed")
3538
# Forward stderr, capture stdout for the filename
36-
result = subprocess.run([find_uv_bin()] + args, stdout=subprocess.PIPE)
39+
result = subprocess.run([uv_bin] + args, stdout=subprocess.PIPE)
3740
if result.returncode != 0:
3841
sys.exit(result.returncode)
3942
# If there was extra stdout, forward it (there should not be extra stdout)

0 commit comments

Comments
 (0)