Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions electron/main/python-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { existsSync, readFileSync, writeFileSync, readdirSync } from 'fs'
import { join } from 'path'
import { spawn, execSync } from 'child_process'

const SETUP_VERSION = 1
const SETUP_VERSION = 2
const TOTAL_PACKAGES = 20

interface SetupJson {
version: number
appVersion?: string
}

// ─── Public helpers ──────────────────────────────────────────────────────────
Expand All @@ -18,6 +19,8 @@ export function checkSetupNeeded(userData: string): boolean {
try {
const data = JSON.parse(readFileSync(jsonPath, 'utf-8')) as SetupJson
if (data.version < SETUP_VERSION) return true
// Re-run setup if the app was updated (new python-embed is fresh, no packages)
if (data.appVersion !== app.getVersion()) return true
} catch {
return true
}
Expand All @@ -30,7 +33,11 @@ export function checkSetupNeeded(userData: string): boolean {

export function markSetupDone(userData: string): void {
const jsonPath = join(userData, 'python_setup.json')
writeFileSync(jsonPath, JSON.stringify({ version: SETUP_VERSION }), 'utf-8')
writeFileSync(
jsonPath,
JSON.stringify({ version: SETUP_VERSION, appVersion: app.getVersion() }),
'utf-8'
)
}

/** Path to the venv Python executable created during setup (packaged Unix). */
Expand Down