From 30163c89829b3c32bdeefcea4a4a888c4092df59 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Wed, 28 Aug 2024 14:48:47 -0700 Subject: [PATCH] Fix pip executable path for windows in standalone command. (#167) * Fixed: Windows forms path using backslash when URLs need forward slashes. * Update. * Remove unused dependency. * Different executable paths for Windows / Unix * Fix. * Rename to StandalonePython. --- comfy_cli/standalone.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/comfy_cli/standalone.py b/comfy_cli/standalone.py index 6663bfc..95302c5 100644 --- a/comfy_cli/standalone.py +++ b/comfy_cli/standalone.py @@ -1,3 +1,4 @@ +import platform import shutil import subprocess import tarfile @@ -85,7 +86,7 @@ def FromDistro( return StandalonePython.FromTarball(fpath, name) @staticmethod - def FromTarball(fpath: PathLike, name: PathLike = "python"): + def FromTarball(fpath: PathLike, name: PathLike = "python") -> "StandalonePython": fpath = Path(fpath) with tarfile.open(fpath) as tar: @@ -103,7 +104,10 @@ def FromTarball(fpath: PathLike, name: PathLike = "python"): tar.extractall() shutil.move(old_rpath, rpath) - return StandalonePython(rpath=rpath) + + if platform.system() == "Windows": + return StandlonePythonWindows(rpath=rpath) + return StandalonePythonUnix(rpath=rpath) def __init__(self, rpath: PathLike): self.rpath = Path(rpath) @@ -209,3 +213,19 @@ def _filter(tinfo: tarfile.TarInfo): if progress: barProg.advance(addTar, _size) pathProg.update(pathTar, description="") + + +class StandalonePythonUnix(StandalonePython): + def get_bin_path(self) -> Path: + return self.rpath / "bin" + + def get_executable_path(self) -> Path: + return self.bin / "python" + + +class StandlonePythonWindows(StandalonePython): + def get_bin_path(self) -> Path: + return self.rpath + + def get_executable_path(self) -> Path: + return self.bin / "python.exe"