mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-17 22:07:47 +00:00
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 <cthoyt@gmail.com>
This commit is contained in:
parent
c4d0caaee5
commit
ff860296c5
1 changed files with 6 additions and 3 deletions
|
@ -26,14 +26,17 @@ def warn_config_settings(config_settings: "dict | None" = None):
|
||||||
|
|
||||||
def call(args: "list[str]", config_settings: "dict | None" = None) -> str:
|
def call(args: "list[str]", config_settings: "dict | None" = None) -> str:
|
||||||
"""Invoke a uv subprocess and return the filename from stdout."""
|
"""Invoke a uv subprocess and return the filename from stdout."""
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ._find_uv import find_uv_bin
|
|
||||||
|
|
||||||
warn_config_settings(config_settings)
|
warn_config_settings(config_settings)
|
||||||
|
# Unlike `find_uv_bin`, this mechanism must work according to PEP 517
|
||||||
|
uv_bin = shutil.which("uv")
|
||||||
|
if uv_bin is None:
|
||||||
|
raise RuntimeError("uv was not properly installed")
|
||||||
# Forward stderr, capture stdout for the filename
|
# Forward stderr, capture stdout for the filename
|
||||||
result = subprocess.run([find_uv_bin()] + args, stdout=subprocess.PIPE)
|
result = subprocess.run([uv_bin] + args, stdout=subprocess.PIPE)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
sys.exit(result.returncode)
|
sys.exit(result.returncode)
|
||||||
# If there was extra stdout, forward it (there should not be extra stdout)
|
# If there was extra stdout, forward it (there should not be extra stdout)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue