Files
nixpkgs/pkgs/development/python-modules/hatch/inject-uv-path.patch

62 lines
2.2 KiB
Diff

diff --git a/src/hatch/env/virtual.py b/src/hatch/env/virtual.py
index 7a9b7e65..38f69fb7 100644
--- a/src/hatch/env/virtual.py
+++ b/src/hatch/env/virtual.py
@@ -108,29 +108,7 @@ class VirtualEnvironment(EnvironmentInterface):
@cached_property
def uv_path(self) -> str:
- if self.explicit_uv_path:
- return self.explicit_uv_path
-
- from hatch.env.internal import is_default_environment
-
- env_name = "hatch-uv"
- if not (
- # Prevent recursive loop
- self.name == env_name
- # Only if dependencies have been set by the user
- or is_default_environment(env_name, self.app.project.config.internal_envs[env_name])
- ):
- uv_env = self.app.project.get_environment(env_name)
- self.app.project.prepare_environment(uv_env, keep_env=bool(os.environ.get(AppEnvVars.KEEP_ENV)))
- with uv_env:
- return self.platform.modules.shutil.which("uv")
-
- import sysconfig
-
- scripts_dir = sysconfig.get_path("scripts")
- old_path = os.environ.get("PATH", os.defpath)
- new_path = f"{scripts_dir}{os.pathsep}{old_path}"
- return self.platform.modules.shutil.which("uv", path=new_path)
+ return "@uv@"
@cached_property
def distributions(self) -> InstalledDistributions:
diff --git a/src/hatch/venv/core.py b/src/hatch/venv/core.py
index d8c6379e..874f8936 100644
--- a/src/hatch/venv/core.py
+++ b/src/hatch/venv/core.py
@@ -131,7 +131,7 @@ class TempVirtualEnv(VirtualEnv):
class UVVirtualEnv(VirtualEnv):
def create(self, python, *, allow_system_packages=False):
- command = [os.environ.get("HATCH_UV", "uv"), "venv", str(self.directory), "--python", python]
+ command = [os.environ.get("HATCH_UV", "@uv@"), "venv", str(self.directory), "--python", python]
if allow_system_packages:
command.append("--system-site-packages")
diff --git a/tests/conftest.py b/tests/conftest.py
index b47e90e8..542035d9 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -205,7 +205,7 @@ def python_on_path():
@pytest.fixture(scope="session", autouse=True)
def uv_on_path():
- return shutil.which("uv")
+ return "@uv@"
@pytest.fixture(scope="session")