From fc93f550e0caa2244807f77b6bfd7efb2a001705 Mon Sep 17 00:00:00 2001 From: bruno Date: Sun, 26 Jul 2026 11:02:57 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20r=C3=A9soudre=20python-embed=20relativem?= =?UTF-8?q?ent=20=C3=A0=20l'exe=20+=20copier=20runtime=20dans=20output=20d?= =?UTF-8?q?ir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - main.rs: utiliser current_exe().parent() au lieu de ./ relatif au cwd - build-windows.bat: étape 5b qui copie python-embed/ et backend/ dans target/release --- desktop/build-windows.bat | 12 +++++++++++- desktop/src/main.rs | 11 +++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/desktop/build-windows.bat b/desktop/build-windows.bat index 08b639e..1a61675 100644 --- a/desktop/build-windows.bat +++ b/desktop/build-windows.bat @@ -53,7 +53,17 @@ if errorlevel 1 ( ) echo ✅ Build successful -REM ── 6. Signer (optionnel) ───────────────────────────────────── +REM ── 5b. Copier python-embed à côté de l'exécutable pour le dev ───── +echo [5b/6] Copying python-embed to output dir... +set "OUTDIR=target\x86_64-pc-windows-msvc\release" +if exist "%OUTDIR%\python-embed" rmdir /s /q "%OUTDIR%\python-embed" +xcopy /E /I /Q "python-embed" "%OUTDIR%\python-embed" +REM Copier aussi le backend Python +if not exist "%OUTDIR%\backend" mkdir "%OUTDIR%\backend" +xcopy /E /I /Q "..\backend" "%OUTDIR%\backend" +echo ✅ Runtime copied + +REM ── 6. Résultats ─────────────────────────────────────────────────── echo [6/6] Results: dir /b target\release\bundle\msi\*.msi 2>nul dir /b target\release\bundle\nsis\*.exe 2>nul diff --git a/desktop/src/main.rs b/desktop/src/main.rs index 69cfe33..c0678a9 100644 --- a/desktop/src/main.rs +++ b/desktop/src/main.rs @@ -10,10 +10,17 @@ struct BackendProcess(Mutex>); // ── Sidecar : spawn Python backend ────────────────────────────────────────── fn spawn_backend() -> Result { + // Resolve python-embed relative to the executable, not cwd + let exe_dir = std::env::current_exe() + .map_err(|e| format!("Cannot get exe path: {}", e))? + .parent() + .ok_or("Cannot get exe parent dir")? + .to_path_buf(); + let python = if cfg!(target_os = "windows") { - "./python-embed/python.exe" + exe_dir.join("python-embed").join("python.exe") } else { - "./python-embed/bin/python3" + exe_dir.join("python-embed").join("bin").join("python3") }; let child = Command::new(python)