Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Move onnxruntime installation to build.rs (#729)

Neptuneeccab4d44396
diff --git a/screenpipe-app-tauri/scripts/pre_build.js b/screenpipe-app-tauri/scripts/pre_build.js
index e867faa32..c52418d7c 100644
--- a/screenpipe-app-tauri/scripts/pre_build.js
+++ b/screenpipe-app-tauri/scripts/pre_build.js
@@ -314,28 +314,6 @@ if (platform == 'windows') {
await $`rm -rf ${config.windows.ffmpegName}.7z`
}
- // Setup ONNX Runtime
- const onnxRuntimeName = "onnxruntime-win-x64-gpu-1.19.2";
- const onnxRuntimeLibs = `${onnxRuntimeName}.zip`;
- const onnxRuntimeUrl = `https://github.com/microsoft/onnxruntime/releases/download/v1.19.2/${onnxRuntimeLibs}`
- if (!(await fs.exists(onnxRuntimeName))) {
- console.log('Setting up ONNX Runtime libraries for Windows...')
- try {
- await $`${wgetPath} --no-config -nc --no-check-certificate --show-progress ${onnxRuntimeUrl} -O ${onnxRuntimeLibs}`
- await $`unzip ${onnxRuntimeLibs} || tar -xf ${onnxRuntimeLibs} || echo "Done extracting"`;
- await $`rm -rf ${onnxRuntimeLibs} || rm ${onnxRuntimeLibs} -Recurse -Force || echo "Done cleaning up zip"`;
- console.log('ONNX Runtime libraries for Windows set up successfully.')
- } catch (error) {
- console.error('Error downloading or extracting ONNX Runtime:', error);
- console.log('Attempting alternative download method...');
- // Add alternative download method here
- }
- } else {
- console.log('ONNX Runtime libraries for Windows already exists.')
- }
-
-
-
// Setup vcpkg packages with environment variables set inline
await $`SystemDrive=${process.env.SYSTEMDRIVE} SystemRoot=${process.env.SYSTEMROOT} windir=${process.env.WINDIR} C:\\vcpkg\\vcpkg.exe install ${config.windows.vcpkgPackages}`.quiet()
}
diff --git a/screenpipe-audio/Cargo.toml b/screenpipe-audio/Cargo.toml
index f7631669f..ad93be874 100644
--- a/screenpipe-audio/Cargo.toml
+++ b/screenpipe-audio/Cargo.toml
@@ -9,6 +9,8 @@ edition = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+[build-dependencies]
+reqwest = { workspace = true }
[dependencies]
serde = { version = "1.0", features = ["derive"] }
@@ -40,12 +42,12 @@ tokenizers = { workspace = true }
anyhow = "1.0.86"
byteorder = "1.5.0"
hf-hub = "0.3.2"
-# https://github.com/pdeljanov/Symphonia/tree/master?tab=readme-ov-file#optimizations
+# https://github.com/pdeljanov/Symphonia/tree/master?tab=readme-ov-file#optimizations
symphonia = { version = "0.5.4", features = ["aac", "isomp4", "opt-simd"] }
rand = "0.8.5"
rubato = "0.15.0"
-# Log
+# Log
log = { workspace = true }
tracing = { workspace = true }
env_logger = "0.10"
diff --git a/screenpipe-audio/build.rs b/screenpipe-audio/build.rs
new file mode 100644
index 000000000..aa55e7227
--- /dev/null
+++ b/screenpipe-audio/build.rs
@@ -0,0 +1,22 @@
+#[cfg(target_os = "windows")]
+use std::{io, fs, process::Command};
+
+fn main() {
+ #[cfg(target_os = "windows")]
+ {
+ let url = "https://github.com/microsoft/onnxruntime/releases/download/v1.19.2/onnxruntime-win-x64-gpu-1.19.2.zip";
+ let resp = reqwest::blocking::get(url).expect("request failed");
+ let body = resp.text().expect("body invalid");
+ let mut out = fs::File::create("onnxruntime-win-x64-gpu-1.19.2.zip").expect("failed to create file");
+ io::copy(&mut body.as_bytes(), &mut out).expect("failed to copy content");
+ let status = Command::new("unzip")
+ .args(["onnxruntime-win-x64-gpu-1.19.2.zip"])
+ .status()
+ .expect("failed to execute process");
+ if !status.success() {
+ panic!("failed to install onnx binary");
+ }
+ fs::rename("onnxruntime-win-x64-gpu-1.19.2",
+ "../screenpipe-app-tauri/src-tauri/onnxruntime-win-x64-gpu-1.19.2");
+ }
+}