Skip to content

Commit 4c37c76

Browse files
author
Bryan Howard
committed
again
1 parent bac5aa0 commit 4c37c76

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

environment_manager.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212

1313

1414
def is_frozen():
15-
"""Checks if the application is running as a frozen (e.g., Nuitka) executable."""
16-
return getattr(sys, "frozen", False)
15+
"""
16+
Checks if the application is running as a frozen (e.g., Nuitka) executable.
17+
This is the corrected and robust implementation.
18+
"""
19+
# Nuitka sets both 'frozen' and '_MEIPASS' attributes.
20+
return getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")
1721

1822

1923
class ClickableLabel(QLineEdit):
@@ -64,53 +68,48 @@ def run(self):
6468
self.finished.emit(False, f"An unexpected error occurred: {e}")
6569

6670
def run_setup(self):
67-
"""Creates the venv and installs packages."""
6871
self.progress.emit("--- STARTING SETUP PROCESS ---")
6972
if not os.path.exists(self.venv_path):
7073
self.progress.emit(f"Target venv path does not exist: {self.venv_path}")
7174
self.progress.emit("Attempting to create new virtual environment...")
7275

73-
# --- DEBUGGING LOGIC ---
7476
frozen_status = is_frozen()
7577
self.progress.emit(f"DEBUG: is_frozen() returned: {frozen_status}")
7678
self.progress.emit(f"DEBUG: sys.executable is: {sys.executable}")
77-
# --- END DEBUGGING ---
79+
self.progress.emit(f"DEBUG: os.path.abspath(__file__) is: {os.path.abspath(__file__)}")
7880

7981
if frozen_status:
8082
self.progress.emit("INFO: Running in FROZEN mode (compiled executable).")
8183

82-
# --- DEBUGGING LOGIC ---
8384
base_path = os.path.dirname(sys.executable)
84-
self.progress.emit(f"DEBUG: Determined base_path from sys.executable: {base_path}")
85+
self.progress.emit(f"DEBUG (FROZEN): Determined base_path from sys.executable: {base_path}")
8586

8687
runtime_python_home = os.path.join(base_path, "python_runtime")
87-
self.progress.emit(f"DEBUG: Constructed python_runtime path: {runtime_python_home}")
88+
self.progress.emit(f"DEBUG (FROZEN): Constructed python_runtime path: {runtime_python_home}")
8889

8990
runtime_python_exe = os.path.join(runtime_python_home, "python.exe")
90-
self.progress.emit(f"DEBUG: Constructed runtime_python_exe path: {runtime_python_exe}")
91+
self.progress.emit(f"DEBUG (FROZEN): Constructed runtime_python_exe path: {runtime_python_exe}")
9192

92-
self.progress.emit(f"DEBUG: Checking if runtime_python_exe exists...")
93+
self.progress.emit(f"DEBUG (FROZEN): Checking if runtime_python_exe exists...")
9394
if not os.path.exists(runtime_python_exe):
9495
self.progress.emit(f"CRITICAL FAILURE: Bundled Python not found at '{runtime_python_exe}'.")
9596
self.finished.emit(False, f"Bundled Python runtime not found at '{runtime_python_exe}'.")
9697
return
97-
self.progress.emit("DEBUG: runtime_python_exe found.")
98-
# --- END DEBUGGING ---
98+
self.progress.emit("DEBUG (FROZEN): runtime_python_exe found.")
9999

100-
# This command is the equivalent of: 'C:\path\to\runtime\python.exe -m venv C:\path\to\.venv_graph'
101100
cmd = [runtime_python_exe, "-m", "venv", self.venv_path]
102-
self.progress.emit(f"DEBUG: Subprocess command to run: {cmd}")
103-
self.progress.emit(f"DEBUG: Subprocess working directory (cwd): {runtime_python_home}")
101+
self.progress.emit(f"DEBUG (FROZEN): Subprocess command to run: {cmd}")
102+
self.progress.emit(f"DEBUG (FROZEN): Subprocess working directory (cwd): {runtime_python_home}")
104103

105104
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", cwd=runtime_python_home)
106105

107106
if result.returncode != 0:
108-
self.progress.emit(f"ERROR: Subprocess failed with return code {result.returncode}.")
107+
self.progress.emit(f"ERROR (FROZEN): Subprocess failed with return code {result.returncode}.")
109108
self.progress.emit(f"ERROR STDOUT: {result.stdout}")
110109
self.progress.emit(f"ERROR STDERR: {result.stderr}")
111110
self.finished.emit(False, f"Failed to create venv. See log for details.")
112111
return
113-
self.progress.emit("INFO: Subprocess to create venv completed successfully.")
112+
self.progress.emit("INFO (FROZEN): Subprocess to create venv completed successfully.")
114113
else:
115114
self.progress.emit("INFO: Running in SCRIPT mode (development).")
116115
venv.create(self.venv_path, with_pip=True)

0 commit comments

Comments
 (0)