Skip to content

Commit 75ea285

Browse files
committed
Restore the uv extra, look for uv under sys.prefix
1 parent 7d3ecf6 commit 75ea285

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ docs = [
5050
"sphinx-issues >= 3.0.0",
5151
]
5252
test = [
53-
"build[virtualenv]",
53+
"build[uv, virtualenv]",
5454
"filelock >= 3",
5555
"pytest >= 6.2.4",
5656
"pytest-cov >= 2.12",
@@ -62,15 +62,18 @@ test = [
6262
'setuptools >= 56.0.0; python_version == "3.10"',
6363
'setuptools >= 56.0.0; python_version == "3.11"',
6464
'setuptools >= 67.8.0; python_version >= "3.12"',
65-
"uv >= 0.1.15",
6665
]
6766
typing = [
67+
"build[uv]",
6868
"importlib-metadata >= 5.1",
6969
"mypy ~= 1.5.0",
7070
"tomli",
7171
"typing-extensions >= 3.7.4.3",
7272
"uv >= 0.1.15",
7373
]
74+
uv = [
75+
"uv >= 0.1.15",
76+
]
7477
virtualenv = [
7578
"virtualenv >= 20.0.35",
7679
]

src/build/env.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,19 @@ def create(self, path: str) -> None:
282282

283283
self._env_path = path
284284

285-
uv_bin = shutil.which('uv')
285+
# ``uv.find_uv_bin`` will look for uv in the user prefix if it can't
286+
# find it under ``sys.prefix``, essentially potentially rearranging
287+
# the user's $PATH. We'll only look for uv under the prefix of
288+
# the running interpreter for unactivated venvs then defer to $PATH.
289+
uv_bin = shutil.which('uv', path=sysconfig.get_path('scripts'))
290+
291+
if not uv_bin:
292+
uv_bin = shutil.which('uv')
293+
286294
if not uv_bin:
287295
msg = 'uv executable missing'
288296
raise RuntimeError(msg)
297+
289298
self._uv_bin = uv_bin
290299

291300
if sys.implementation.name == 'pypy':

tests/test_env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import subprocess
77
import sys
88
import sysconfig
9+
import typing
910

1011
from pathlib import Path
1112
from types import SimpleNamespace
@@ -64,6 +65,7 @@ def test_venv_executable_missing_post_creation(
6465
assert venv_create.call_count == 1
6566

6667

68+
@typing.no_type_check
6769
def test_isolated_env_abstract():
6870
with pytest.raises(TypeError):
6971
build.env.IsolatedEnv()

0 commit comments

Comments
 (0)