MCPcopy
hub / github.com/lightningpixel/modly / runFullSetup

Function runFullSetup

electron/main/python-setup.ts:295–336  ·  view source on GitHub ↗
(win: BrowserWindow, userData: string)

Source from the content-addressed store, hash-verified

293// ─── Public orchestrator ──────────────────────────────────────────────────────
294
295export 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}

Callers 1

setupIpcHandlersFunction · 0.90

Calls 9

getRequirementsPathFunction · 0.85
getVenvDirFunction · 0.85
createVenvFunction · 0.85
getVenvPythonExeFunction · 0.85
installRequirementsFunction · 0.85
getEmbeddedPythonExeFunction · 0.85
findSystemPythonFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected