|
12 | 12 |
|
13 | 13 |
|
14 | 14 | 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") |
17 | 21 |
|
18 | 22 |
|
19 | 23 | class ClickableLabel(QLineEdit): |
@@ -64,53 +68,48 @@ def run(self): |
64 | 68 | self.finished.emit(False, f"An unexpected error occurred: {e}") |
65 | 69 |
|
66 | 70 | def run_setup(self): |
67 | | - """Creates the venv and installs packages.""" |
68 | 71 | self.progress.emit("--- STARTING SETUP PROCESS ---") |
69 | 72 | if not os.path.exists(self.venv_path): |
70 | 73 | self.progress.emit(f"Target venv path does not exist: {self.venv_path}") |
71 | 74 | self.progress.emit("Attempting to create new virtual environment...") |
72 | 75 |
|
73 | | - # --- DEBUGGING LOGIC --- |
74 | 76 | frozen_status = is_frozen() |
75 | 77 | self.progress.emit(f"DEBUG: is_frozen() returned: {frozen_status}") |
76 | 78 | 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__)}") |
78 | 80 |
|
79 | 81 | if frozen_status: |
80 | 82 | self.progress.emit("INFO: Running in FROZEN mode (compiled executable).") |
81 | 83 |
|
82 | | - # --- DEBUGGING LOGIC --- |
83 | 84 | 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}") |
85 | 86 |
|
86 | 87 | 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}") |
88 | 89 |
|
89 | 90 | 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}") |
91 | 92 |
|
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...") |
93 | 94 | if not os.path.exists(runtime_python_exe): |
94 | 95 | self.progress.emit(f"CRITICAL FAILURE: Bundled Python not found at '{runtime_python_exe}'.") |
95 | 96 | self.finished.emit(False, f"Bundled Python runtime not found at '{runtime_python_exe}'.") |
96 | 97 | return |
97 | | - self.progress.emit("DEBUG: runtime_python_exe found.") |
98 | | - # --- END DEBUGGING --- |
| 98 | + self.progress.emit("DEBUG (FROZEN): runtime_python_exe found.") |
99 | 99 |
|
100 | | - # This command is the equivalent of: 'C:\path\to\runtime\python.exe -m venv C:\path\to\.venv_graph' |
101 | 100 | 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}") |
104 | 103 |
|
105 | 104 | result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", cwd=runtime_python_home) |
106 | 105 |
|
107 | 106 | 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}.") |
109 | 108 | self.progress.emit(f"ERROR STDOUT: {result.stdout}") |
110 | 109 | self.progress.emit(f"ERROR STDERR: {result.stderr}") |
111 | 110 | self.finished.emit(False, f"Failed to create venv. See log for details.") |
112 | 111 | return |
113 | | - self.progress.emit("INFO: Subprocess to create venv completed successfully.") |
| 112 | + self.progress.emit("INFO (FROZEN): Subprocess to create venv completed successfully.") |
114 | 113 | else: |
115 | 114 | self.progress.emit("INFO: Running in SCRIPT mode (development).") |
116 | 115 | venv.create(self.venv_path, with_pip=True) |
|
0 commit comments