Skip to content

Commit

Permalink
hatch: tests: Update uv command search
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetrigo committed Jan 11, 2025
1 parent b1838f8 commit 306dd82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/hatch/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from hatch.utils.platform import Platform
from hatch.utils.runner import ExecutionContext

from uv import find_uv_bin

if TYPE_CHECKING:
from collections.abc import Generator

Expand Down Expand Up @@ -160,7 +162,8 @@ def ensure_plugin_dependencies(self, dependencies: list[Requirement], *, wait_me
if dependencies_in_sync(dependencies):
return

pip_command = [sys.executable, '-u', '-m', 'uv', 'pip']
uv_bin = find_uv_bin()
pip_command = [uv_bin, 'pip']

pip_command.extend(['install'])

Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from click.testing import CliRunner as __CliRunner
from filelock import FileLock
from platformdirs import user_cache_dir, user_data_dir
from uv import find_uv_bin

from hatch.config.constants import AppEnvVars, ConfigEnvVars, PublishEnvVars
from hatch.config.user import ConfigFile
Expand Down Expand Up @@ -440,7 +441,8 @@ def _mock(command, **kwargs):
mocked_subprocess_run(command, **kwargs)
return mocked_subprocess_run

if command[:6] == [sys.executable, '-u', '-m', 'uv', 'pip', 'install']:
uv_bin = find_uv_bin()
if command[:3] == [uv_bin, 'pip', 'install']:
mocked_subprocess_run(command, **kwargs)
return mocked_subprocess_run

Expand Down
4 changes: 3 additions & 1 deletion tests/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from unittest.mock import call

import tomli_w
from uv import find_uv_bin

from hatch.config.user import RootConfig
from hatch.env.utils import add_verbosity_flag
Expand Down Expand Up @@ -48,7 +49,8 @@ def get_current_timestamp():


def assert_plugin_installation(subprocess_run, dependencies: list[str], *, verbosity=0, count=1):
command = [sys.executable, '-u', '-m', 'uv', 'pip', 'install']
uv_bin = find_uv_bin()
command = [uv_bin, 'pip', 'install']
add_verbosity_flag(command, verbosity, adjustment=-1)
command.extend(dependencies)

Expand Down

0 comments on commit 306dd82

Please sign in to comment.