Skip to content

Commit

Permalink
Restore the uv extra, look for uv under sys.prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Mar 8, 2024
1 parent 7d3ecf6 commit 75ea285
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ docs = [
"sphinx-issues >= 3.0.0",
]
test = [
"build[virtualenv]",
"build[uv, virtualenv]",
"filelock >= 3",
"pytest >= 6.2.4",
"pytest-cov >= 2.12",
Expand All @@ -62,15 +62,18 @@ test = [
'setuptools >= 56.0.0; python_version == "3.10"',
'setuptools >= 56.0.0; python_version == "3.11"',
'setuptools >= 67.8.0; python_version >= "3.12"',
"uv >= 0.1.15",
]
typing = [
"build[uv]",
"importlib-metadata >= 5.1",
"mypy ~= 1.5.0",
"tomli",
"typing-extensions >= 3.7.4.3",
"uv >= 0.1.15",
]
uv = [
"uv >= 0.1.15",
]
virtualenv = [
"virtualenv >= 20.0.35",
]
Expand Down
11 changes: 10 additions & 1 deletion src/build/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,19 @@ def create(self, path: str) -> None:

self._env_path = path

uv_bin = shutil.which('uv')
# ``uv.find_uv_bin`` will look for uv in the user prefix if it can't
# find it under ``sys.prefix``, essentially potentially rearranging
# the user's $PATH. We'll only look for uv under the prefix of
# the running interpreter for unactivated venvs then defer to $PATH.
uv_bin = shutil.which('uv', path=sysconfig.get_path('scripts'))

if not uv_bin:
uv_bin = shutil.which('uv')

if not uv_bin:
msg = 'uv executable missing'
raise RuntimeError(msg)

self._uv_bin = uv_bin

if sys.implementation.name == 'pypy':
Expand Down
2 changes: 2 additions & 0 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import subprocess
import sys
import sysconfig
import typing

from pathlib import Path
from types import SimpleNamespace
Expand Down Expand Up @@ -64,6 +65,7 @@ def test_venv_executable_missing_post_creation(
assert venv_create.call_count == 1


@typing.no_type_check
def test_isolated_env_abstract():
with pytest.raises(TypeError):
build.env.IsolatedEnv()
Expand Down

0 comments on commit 75ea285

Please sign in to comment.