Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pip executable path for windows in standalone command. #167

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading