Skip to content

Commit ada9c2e

Browse files
committed
fix uv path import
1 parent a8bde57 commit ada9c2e

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

zipapps/main.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,30 @@ def _pip_install(cls, target_dir: Path, pip_args: list, uv_path: str = ""):
514514
import subprocess
515515

516516
# use uv and subprocess
517-
args = [
518-
"uv",
519-
"pip",
520-
"install",
521-
"--python",
522-
sys.executable,
523-
"--no-cache-dir",
524-
] + _pip_args[1:]
517+
uv_real_path = Path(uv_path)
518+
if not uv_real_path.is_file():
519+
if uv_path == "uv":
520+
_path = shutil.which(uv_path)
521+
if _path:
522+
uv_real_path = Path(_path)
523+
uv_exec_args = [uv_real_path.resolve().as_posix()]
524+
else:
525+
uv_exec_args = [sys.executable, "-m", "uv"]
526+
else:
527+
raise RuntimeError(f"The uv_path: {uv_path} is not a valid file.")
528+
else:
529+
uv_exec_args = [uv_real_path.resolve().as_posix()]
530+
args = (
531+
uv_exec_args
532+
+ [
533+
"pip",
534+
"install",
535+
"--python",
536+
sys.executable,
537+
"--no-cache-dir",
538+
]
539+
+ _pip_args[1:]
540+
)
525541
cls._log(f"using uv_path: {args}")
526542
result = subprocess.call(
527543
args,

0 commit comments

Comments
 (0)