Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.

Commit b95ea5f

Browse files
committed
fix: no venv when unpacking bento
Signed-off-by: Frost Ming <me@frostming.com>
1 parent 8d0621c commit b95ea5f

3 files changed

Lines changed: 41 additions & 21 deletions

File tree

src/comfy_pack/cli.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,25 @@ def init(dir: str, verbose: int):
262262
is_flag=True,
263263
help="Do not install models",
264264
)
265+
@click.option(
266+
"--no-venv",
267+
is_flag=True,
268+
help="Do not create a virtual environment for ComfyUI",
269+
default=False,
270+
)
265271
@click.option(
266272
"--verbose",
267273
"-v",
268274
count=True,
269275
help="Increase verbosity level (use multiple times for more verbosity)",
270276
)
271277
def unpack_cmd(
272-
cpack: str, dir: str, include_disabled_models: bool, no_models: bool, verbose: int
278+
cpack: str,
279+
dir: str,
280+
include_disabled_models: bool,
281+
no_models: bool,
282+
no_venv: bool,
283+
verbose: int,
273284
):
274285
import rich
275286

@@ -281,6 +292,7 @@ def unpack_cmd(
281292
verbose=verbose,
282293
all_models=include_disabled_models,
283294
prepare_models=not no_models,
295+
no_venv=no_venv,
284296
)
285297
rich.print("\n[green]✓ ComfyUI Workspace is restored![/green]")
286298
rich.print(f"{dir}")

src/comfy_pack/package.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,28 +141,34 @@ def install_dependencies(
141141
workspace: Path,
142142
verbose: int = 0,
143143
no_deps: bool = False,
144+
no_venv: bool = False,
144145
):
145146
print("Installing Python dependencies")
146147
stdout = None if verbose > 0 else subprocess.DEVNULL
147148
stderr = None if verbose > 1 else subprocess.DEVNULL
148-
149-
venv = workspace / ".venv"
150-
if (venv / "DONE").exists():
151-
return
152-
venv_py = (
153-
venv / "Scripts" / "python.exe" if os.name == "nt" else venv / "bin" / "python"
154-
)
155-
subprocess.check_call(
156-
[
157-
"uv",
158-
"venv",
159-
"--python",
160-
python_version,
161-
venv,
162-
],
163-
stdout=stdout,
164-
stderr=stderr,
165-
)
149+
if no_venv:
150+
print("Using the current Python environment")
151+
venv_py = Path(sys.executable)
152+
else:
153+
venv = workspace / ".venv"
154+
if (venv / "DONE").exists():
155+
return
156+
venv_py = (
157+
venv / "Scripts" / "python.exe"
158+
if os.name == "nt"
159+
else venv / "bin" / "python"
160+
)
161+
subprocess.check_call(
162+
[
163+
"uv",
164+
"venv",
165+
"--python",
166+
python_version,
167+
venv,
168+
],
169+
stdout=stdout,
170+
stderr=stderr,
171+
)
166172
subprocess.check_call(
167173
[
168174
"uv",
@@ -403,6 +409,7 @@ def install(
403409
preheat: bool = True,
404410
prepare_models: bool = True,
405411
all_models: bool = False,
412+
no_venv: bool = False,
406413
verbose: int = 0,
407414
):
408415
workspace = Path(workspace)
@@ -427,6 +434,7 @@ def install(
427434
snapshot["python"],
428435
str(workspace / "requirements.txt"),
429436
workspace,
437+
no_venv=no_venv,
430438
verbose=verbose,
431439
)
432440
shutil.copy2(
@@ -453,7 +461,7 @@ def install(
453461
with ComfyUIServer(
454462
str(workspace),
455463
verbose=verbose,
456-
venv=str(workspace / ".venv"),
464+
venv=str(workspace / ".venv") if not no_venv else None,
457465
) as _:
458466
pass
459467
if prepare_models:

src/comfy_pack/setup_workspace.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ if [ -n "$VIRTUAL_ENV" ]; then
1818
fi
1919

2020
set -x
21-
comfy-pack unpack "$CPACK" -d "$workspace" --no-models -v
21+
comfy-pack unpack "$CPACK" -d "$workspace" --no-models --no-venv -v
2222
chown -R bentoml:bentoml "$workspace"
2323
set +x

0 commit comments

Comments
 (0)