Skip to content

Commit

Permalink
Fix pip executable path for windows in standalone command. (#167)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
robinjhuang committed Aug 28, 2024
1 parent 9a31010 commit 30163c8
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions comfy_cli/standalone.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import shutil
import subprocess
import tarfile
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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"

0 comments on commit 30163c8

Please sign in to comment.