Skip to content

Commit

Permalink
fix: always use simplest form if on PATH
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Apr 12, 2024
1 parent c7f07b5 commit 529d632
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import subprocess
import sys
from collections.abc import Callable, Mapping
from pathlib import Path
from socket import gethostbyname
from typing import Any, ClassVar

Expand All @@ -45,17 +46,24 @@


def find_uv() -> tuple[bool, str]:
uv_on_path = shutil.which("uv")

# Look for uv in Nox's environment, to handle `pipx install nox[uv]`.
with contextlib.suppress(ImportError, FileNotFoundError):
from uv import find_uv_bin

uv_bin = find_uv_bin()

if uv_on_path and Path(uv_bin).samefile(uv_on_path):
return True, "uv"

return True, find_uv_bin()

# Fall back to PATH.
if shutil.which("uv") is not None:
return True, "uv"

return False, "uv"
return uv_on_path is not None, "uv"


HAS_UV, UV = find_uv()
Expand Down

0 comments on commit 529d632

Please sign in to comment.