(win: BrowserWindow, userData: string)
| 293 | // ─── Public orchestrator ────────────────────────────────────────────────────── |
| 294 | |
| 295 | export async function runFullSetup(win: BrowserWindow, userData: string): Promise<void> { |
| 296 | try { |
| 297 | const requirementsPath = getRequirementsPath() |
| 298 | const venvDir = getVenvDir(userData) |
| 299 | |
| 300 | if (process.platform === 'linux' && app.isPackaged) { |
| 301 | // AppImage: process.resourcesPath is ephemeral — copy Python to stable userData path first |
| 302 | const pythonExe = await ensureStableEmbeddedPython(userData, win) |
| 303 | await createVenv(pythonExe, venvDir, win) |
| 304 | const venvPython = getVenvPythonExe(userData) |
| 305 | await installRequirements(venvPython, requirementsPath, win) |
| 306 | } else if (process.platform === 'win32' || app.isPackaged) { |
| 307 | // Windows (dev + packaged) or macOS packaged: bundled Python path is stable |
| 308 | const pythonExe = getEmbeddedPythonExe() |
| 309 | if (!existsSync(pythonExe)) { |
| 310 | throw new Error( |
| 311 | 'Bundled Python runtime not found.\n' + |
| 312 | 'Please reinstall the application.\n' + |
| 313 | `(expected: ${pythonExe})` |
| 314 | ) |
| 315 | } |
| 316 | await createVenv(pythonExe, venvDir, win) |
| 317 | const venvPython = getVenvPythonExe(userData) |
| 318 | await installRequirements(venvPython, requirementsPath, win) |
| 319 | } else { |
| 320 | // Linux / macOS dev: use system Python |
| 321 | win.webContents.send('setup:progress', { step: 'venv', percent: 5 }) |
| 322 | const python3 = findSystemPython() |
| 323 | await createVenv(python3, venvDir, win) |
| 324 | const venvPython = getVenvPythonExe(userData) |
| 325 | await installRequirements(venvPython, requirementsPath, win) |
| 326 | } |
| 327 | |
| 328 | win.webContents.send('setup:complete') |
| 329 | console.log('[PythonSetup] Setup complete') |
| 330 | } catch (err) { |
| 331 | const message = err instanceof Error ? err.message : String(err) |
| 332 | console.error('[PythonSetup] Error:', message) |
| 333 | win.webContents.send('setup:error', { message }) |
| 334 | throw err |
| 335 | } |
| 336 | } |
no test coverage detected