Skip to content

Commit 51b56db

Browse files
author
Bryan Howard
committed
changing up how it's determining what it's location is in the 2 states. compiled vs python
1 parent 87a09a2 commit 51b56db

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

environment_manager.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,24 @@ def run_setup(self):
7070

7171
if is_frozen():
7272
# --- Definitive Fix for Frozen Apps ---
73-
# Instead of running venv from within the frozen app, we use a subprocess
74-
# to call the bundled python.exe and tell IT to create the venv.
75-
# This completely isolates the process and ensures the correct executable is used.
76-
base_path = os.path.dirname(sys.executable)
77-
runtime_python_exe = os.path.join(base_path, "python_runtime", "python.exe")
73+
# Determine the base path correctly depending on whether the app is frozen or not.
74+
if is_frozen():
75+
# When frozen, the base path is the directory of the executable.
76+
base_path = os.path.dirname(sys.executable)
77+
else:
78+
# When running from source, the base path is the directory of this script.
79+
base_path = os.path.dirname(os.path.abspath(__file__))
80+
81+
runtime_python_home = os.path.join(base_path, "python_runtime")
82+
runtime_python_exe = os.path.join(runtime_python_home, "python.exe")
7883

7984
if not os.path.exists(runtime_python_exe):
8085
self.finished.emit(False, f"Bundled Python runtime not found at '{runtime_python_exe}'.")
8186
return
8287

83-
# This command is the equivalent of running 'python -m venv .venv_graph' from the command line.
88+
# Use the bundled python.exe to create the venv from the command line.
8489
cmd = [runtime_python_exe, "-m", "venv", self.venv_path]
85-
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8")
90+
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", cwd=runtime_python_home)
8691

8792
if result.returncode != 0:
8893
self.finished.emit(False, f"Failed to create venv: {result.stderr}")
@@ -182,7 +187,6 @@ def __init__(self, venv_path, requirements, parent=None):
182187
action_layout.addWidget(self.verify_button)
183188
layout.addLayout(action_layout)
184189

185-
# UI FIX: Use the custom ClickableLabel for the status display.
186190
self.status_display = ClickableLabel("Status: Ready")
187191
layout.addWidget(self.status_display)
188192

0 commit comments

Comments
 (0)