Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

setup process updated

tilakpatel22b1dba7861cf8
diff --git a/fincept-terminal-desktop/src-tauri/resources/requirements-numpy1.txt b/fincept-terminal-desktop/src-tauri/resources/requirements-numpy1.txt
index 7b445b970..423bfa995 100644
--- a/fincept-terminal-desktop/src-tauri/resources/requirements-numpy1.txt
+++ b/fincept-terminal-desktop/src-tauri/resources/requirements-numpy1.txt
@@ -76,7 +76,7 @@ cvxopt==1.3.2
# Visualization
matplotlib>=3.8.0,<3.10.0
-plotly==6.5.0
+plotly>=5.18.0,<6.0.0
seaborn>=0.12.0
jinja2==3.1.3
weasyprint==62.3
diff --git a/fincept-terminal-desktop/src-tauri/resources/requirements-numpy2.txt b/fincept-terminal-desktop/src-tauri/resources/requirements-numpy2.txt
index ad043bf79..466795680 100644
--- a/fincept-terminal-desktop/src-tauri/resources/requirements-numpy2.txt
+++ b/fincept-terminal-desktop/src-tauri/resources/requirements-numpy2.txt
@@ -5,7 +5,7 @@
numpy>=2.2.3,<3.0
pandas>=2.3.3,<3.0
-# Trading platform (requires NumPy 2.x)
+# Trading platform (requires NumPy 2.2+)
vnpy==4.3.0
# Data fetching
@@ -14,6 +14,11 @@ aiohttp==3.13.2
websockets==15.0.1
beautifulsoup4==4.14.2
protobuf>=3.20.2,<6.0.0
+yfinance==0.2.66
+databento==0.66.0
+databento-dbn==0.44.0
+feedparser==6.0.12
+gnews==0.4.2
# SEC EDGAR data
edgartools>=5.6.0
@@ -28,11 +33,49 @@ litellm>=1.73
tiktoken>=0.5.0
# ML/DL (NumPy 2.x compatible)
-torch>=2.0.0
+torch>=2.3.1
+scikit-learn>=1.4.2,<1.7.0
+scipy>=1.13.0,<1.16.0
+lightgbm>=4.6.0,<5.0.0
+xgboost>=2.1.0,<2.2.0
+catboost>=1.2.0,<1.3.0
+
+# Time series and forecasting (NumPy 2.x compatible)
+statsmodels>=0.14.2
+pmdarima>=2.1.1
+
+# Technical analysis
+ta==0.11.0
+talipp==2.7.0
+
+# Portfolio optimization
+# Note: PyPortfolioOpt moved to NumPy 1.x due to plotly<6.0.0 requirement
+finquant-enhanced
+cvxpy>=1.0.0
+cvxopt==1.3.2
+
+# Financial modeling
+py_vollib==1.0.1
+pypme==0.6.2
+# financepy moved to NumPy 1.x (requires old numba incompatible with Python 3.12)
+ffn==1.1.2
+fortitudo.tech==1.2
+rateslib==2.1.1
+
+# Quant libraries
+pyqlib==0.9.7
+rdagent==0.8.0
+gs-quant==1.4.67
+
+# Time series (additional)
+tsmoothie==1.0.5
# Visualization
-plotly==6.5.0
+plotly>=6.0.0
matplotlib>=3.9.3,<4.0
+seaborn>=0.12.0
+jinja2==3.1.3
+weasyprint==62.3
# Development tools
jupyter>=1.0.0
@@ -52,3 +95,41 @@ python-redis-lock>=4.0.0
setuptools-scm>=8.0.0
tables>=3.8.0
selenium>=4.0.0
+pyarrow>=16.0.0
+
+# Database
+peewee>=3.17.0,<3.18.0
+
+# MLflow
+mlflow>=2.0.0
+
+# Additional data utilities
+aiohappyeyeballs==2.6.1
+aiosignal==1.4.0
+attrs==25.4.0
+certifi==2025.11.12
+cffi==2.0.0
+charset-normalizer==3.4.4
+curl_cffi==0.13.0
+dnspython==2.8.0
+frozendict==2.4.7
+frozenlist==1.8.0
+idna==3.11
+multidict==6.7.0
+multitasking==0.0.12
+pip_system_certs==5.3
+platformdirs==4.5.0
+propcache==0.4.1
+pycparser==2.23
+python-dateutil==2.9.0.post0
+pytz==2025.2
+sgmllib3k==1.0.0
+six==1.17.0
+soupsieve==2.8
+typing_extensions==4.15.0
+tzdata==2025.2
+urllib3==2.5.0
+yarl==1.22.0
+zstandard==0.25.0
+pandarallel>=1.6.0
+gym>=0.26.0
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/backtesting.rs b/fincept-terminal-desktop/src-tauri/src/commands/backtesting.rs
index 0519782e4..9be5bc10e 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/backtesting.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/backtesting.rs
@@ -174,6 +174,7 @@ pub async fn kill_lean_process(
* Execute Python backtesting provider
*
* Runs a Python provider script with given command and arguments.
+ * Automatically selects the correct Python venv based on provider.
*/
#[tauri::command]
pub async fn execute_python_backtest(
@@ -182,8 +183,8 @@ pub async fn execute_python_backtest(
args: String,
app: tauri::AppHandle,
) -> Result<String, String> {
- // Use the central get_python_path utility which handles dev/prod mode correctly
- let python_path = python::get_python_path(&app)?;
+ // Use library-specific Python path (switches between numpy1/numpy2 venvs)
+ let python_path = python::get_python_path_for_library(&app, Some(&provider))?;
// Build script path - handle both dev and production
let script_relative_path = format!(
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/pmdarima.rs b/fincept-terminal-desktop/src-tauri/src/commands/pmdarima.rs
index 83a88037a..81739d202 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/pmdarima.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/pmdarima.rs
@@ -5,7 +5,6 @@
*/
use std::process::Command;
-use serde_json::Value;
/// Execute Python script and return JSON result
fn execute_python_script(script_name: &str, function: &str, args: &str) -> Result<String, String> {
diff --git a/fincept-terminal-desktop/src-tauri/src/lib.rs b/fincept-terminal-desktop/src-tauri/src/lib.rs
index 0144b2ddd..309335aec 100644
--- a/fincept-terminal-desktop/src-tauri/src/lib.rs
+++ b/fincept-terminal-desktop/src-tauri/src/lib.rs
@@ -449,7 +449,7 @@ async fn ws_reconnect(
/// Add monitoring condition
#[tauri::command]
async fn monitor_add_condition(
- app: tauri::AppHandle,
+ _app: tauri::AppHandle,
state: tauri::State<'_, WebSocketState>,
condition: websocket::services::monitoring::MonitorCondition,
) -> Result<i64, String> {
@@ -496,7 +496,7 @@ async fn monitor_add_condition(
/// Get all monitoring conditions
#[tauri::command]
async fn monitor_get_conditions(
- app: tauri::AppHandle,
+ _app: tauri::AppHandle,
) -> Result<Vec<websocket::services::monitoring::MonitorCondition>, String> {
let pool = database::pool::get_pool().map_err(|e| e.to_string())?;
let conn = pool.get().map_err(|e| e.to_string())?;
@@ -530,7 +530,7 @@ async fn monitor_get_conditions(
/// Delete monitoring condition
#[tauri::command]
async fn monitor_delete_condition(
- app: tauri::AppHandle,
+ _app: tauri::AppHandle,
state: tauri::State<'_, WebSocketState>,
id: i64,
) -> Result<(), String> {
@@ -552,7 +552,7 @@ async fn monitor_delete_condition(
/// Get recent alerts
#[tauri::command]
async fn monitor_get_alerts(
- app: tauri::AppHandle,
+ _app: tauri::AppHandle,
limit: i64,
) -> Result<Vec<websocket::services::monitoring::MonitorAlert>, String> {
use rusqlite::params;
diff --git a/fincept-terminal-desktop/src-tauri/src/setup.rs b/fincept-terminal-desktop/src-tauri/src/setup.rs
index b6a7d0f1d..6a70358dd 100644
--- a/fincept-terminal-desktop/src-tauri/src/setup.rs
+++ b/fincept-terminal-desktop/src-tauri/src/setup.rs
@@ -1,8 +1,7 @@
-// setup.rs - Clean setup for Python, Bun, and UV package manager
+// setup.rs - Simplified Python and Bun setup
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::process::Command;
-use std::fs;
use std::sync::Mutex;
use tauri::{AppHandle, Emitter, Manager};
@@ -25,16 +24,12 @@ pub struct SetupProgress {
pub struct SetupStatus {
pub python_installed: bool,
pub bun_installed: bool,
- pub uv_installed: bool,
pub packages_installed: bool,
- pub packages_numpy1_installed: bool,
- pub packages_numpy2_installed: bool,
pub needs_setup: bool,
}
const PYTHON_VERSION: &str = "3.12.7";
const BUN_VERSION: &str = "1.1.0";
-const UV_VERSION: &str = "0.9.18";
fn emit_progress(app: &AppHandle, step: &str, progress: u8, message: &str, is_error: bool) {
let _ = app.emit("setup-progress", SetupProgress {
@@ -46,15 +41,12 @@ fn emit_progress(app: &AppHandle, step: &str, progress: u8, message: &str, is_er
eprintln!("[SETUP] [{}] {}% - {}", step, progress, message);
}
-/// Detect if running in dev mode
fn is_dev_mode() -> bool {
cfg!(debug_assertions)
}
-/// Get installation directory based on mode
fn get_install_dir(app: &AppHandle) -> Result<PathBuf, String> {
if is_dev_mode() {
- // Dev mode: use OS-specific user directory (no admin needed)
let base_dir = if cfg!(target_os = "windows") {
std::env::var("LOCALAPPDATA")
.map(PathBuf::from)
@@ -64,14 +56,12 @@ fn get_install_dir(app: &AppHandle) -> Result<PathBuf, String> {
.map(|h| PathBuf::from(h).join("Library/Application Support"))
.unwrap_or_else(|_| PathBuf::from("/tmp"))
} else {
- // Linux
std::env::var("HOME")
.map(|h| PathBuf::from(h).join(".local/share"))
.unwrap_or_else(|_| PathBuf::from("/tmp"))
};
Ok(base_dir.join("fincept-dev"))
} else {
- // Production: use app resource directory
app.path().resource_dir()
.map_err(|e| format!("Failed to get resource dir: {}", e))
}
@@ -108,7 +98,7 @@ fn check_bun(install_dir: &PathBuf) -> (bool, Option<String>) {
let bun_exe = if cfg!(target_os = "windows") {
install_dir.join("bun/bun.exe")
} else {
- install_dir.join("bun/bun")
+ install_dir.join("bun/bin/bun")
};
if !bun_exe.exists() {
@@ -129,647 +119,233 @@ fn check_bun(install_dir: &PathBuf) -> (bool, Option<String>) {
(false, None)
}
-/// Check UV installation
-fn check_uv(install_dir: &PathBuf) -> bool {
- let uv_exe = if cfg!(target_os = "windows") {
- install_dir.join("python/Scripts/uv.exe")
- } else {
- install_dir.join("python/bin/uv")
- };
- uv_exe.exists()
-}
-
-/// Check if packages are installed (either environment)
+/// Check if Python packages are installed in both venvs
fn check_packages(install_dir: &PathBuf) -> bool {
- check_packages_numpy1(install_dir) || check_packages_numpy2(install_dir)
-}
-
-/// Check NumPy 1.x venv
-fn check_packages_numpy1(install_dir: &PathBuf) -> bool {
- let venv_python = if cfg!(target_os = "windows") {
+ let venv1_python = if cfg!(target_os = "windows") {
install_dir.join("venv-numpy1/Scripts/python.exe")
} else {
install_dir.join("venv-numpy1/bin/python3")
};
- if !venv_python.exists() {
- return false;
- }
-
- let mut cmd = Command::new(&venv_python);
- cmd.args(&["-c", "import gluonts, yfinance, numpy"]);
- #[cfg(target_os = "windows")]
- cmd.creation_flags(CREATE_NO_WINDOW);
-
- cmd.output().map(|o| o.status.success()).unwrap_or(false)
-}
-
-/// Check NumPy 2.x venv
-fn check_packages_numpy2(install_dir: &PathBuf) -> bool {
- let venv_python = if cfg!(target_os = "windows") {
+ let venv2_python = if cfg!(target_os = "windows") {
install_dir.join("venv-numpy2/Scripts/python.exe")
} else {
install_dir.join("venv-numpy2/bin/python3")
};
- if !venv_python.exists() {
+ if !venv1_python.exists() || !venv2_python.exists() {
return false;
}
- let mut cmd = Command::new(&venv_python);
- cmd.args(&["-c", "import vnpy, edgartools, numpy"]);
+ // Check numpy1 venv for key packages
+ let mut cmd1 = Command::new(&venv1_python);
+ cmd1.args(&["-c", "import numpy, pandas, vectorbt, backtesting"]);
#[cfg(target_os = "windows")]
- cmd.creation_flags(CREATE_NO_WINDOW);
-
- cmd.output().map(|o| o.status.success()).unwrap_or(false)
-}
+ cmd1.creation_flags(CREATE_NO_WINDOW);
+ let check1 = cmd1.output().map(|o| o.status.success()).unwrap_or(false);
+ // Check numpy2 venv for key packages
+ let mut cmd2 = Command::new(&venv2_python);
+ cmd2.args(&["-c", "import numpy, pandas, vnpy, torch"]);
+ #[cfg(target_os = "windows")]
+ cmd2.creation_flags(CREATE_NO_WINDOW);
+ let check2 = cmd2.output().map(|o| o.status.success()).unwrap_or(false);
-/// Download file with progress
-async fn download_file(url: &str, dest: &PathBuf, app: &AppHandle, step: &str) -> Result<(), String> {
- use reqwest;
- use std::io::Write;
- use std::time::Duration;
-
- emit_progress(app, step, 10, &format!("Downloading {}", url.split('/').last().unwrap_or("file")), false);
-
- let client = reqwest::Client::builder()
- .timeout(Duration::from_secs(300))
- .build()
- .map_err(|e| format!("Failed to create client: {}", e))?;
-
- let response = client.get(url).send().await
- .map_err(|e| format!("Download failed: {}", e))?;
-
- let bytes = response.bytes().await
- .map_err(|e| format!("Failed to read response: {}", e))?;
-
- let mut file = fs::File::create(dest)
- .map_err(|e| format!("Failed to create file: {}", e))?;
-
- file.write_all(&bytes)
- .map_err(|e| format!("Failed to write file: {}", e))?;
-
- emit_progress(app, step, 30, "Download complete", false);
- Ok(())
+ check1 && check2
}
-/// Install Python (all platforms)
+/// Install Python
async fn install_python(app: &AppHandle, install_dir: &PathBuf) -> Result<(), String> {
emit_progress(app, "python", 0, "Installing Python...", false);
let python_dir = install_dir.join("python");
- fs::create_dir_all(&python_dir)
- .map_err(|e| format!("Failed to create python dir: {}", e))?;
+ std::fs::create_dir_all(&python_dir)
+ .map_err(|e| format!("Failed to create Python dir: {}", e))?;
+
+ // Download Python embeddable package
+ let download_url = if cfg!(target_os = "windows") {
+ format!("https://www.python.org/ftp/python/{}/python-{}-embed-amd64.zip", PYTHON_VERSION, PYTHON_VERSION)
+ } else {
+ return Err("Auto-install only supported on Windows. Install Python manually.".to_string());
+ };
- let temp_dir = std::env::temp_dir();
+ emit_progress(app, "python", 20, "Downloading Python...", false);
+ // Download using PowerShell
+ let zip_path = python_dir.join("python.zip");
+ let mut cmd = Command::new("powershell");
+ cmd.args(&[
+ "-Command",
+ &format!("Invoke-WebRequest -Uri '{}' -OutFile '{}'", download_url, zip_path.display())
+ ]);
#[cfg(target_os = "windows")]
- {
- // Windows: Download embedded Python ZIP
- let url = "https://www.python.org/ftp/python/3.12.7/python-3.12.7-embed-amd64.zip";
- let zip_path = temp_dir.join("python.zip");
- download_file(url, &zip_path, app, "python").await?;
-
- emit_progress(app, "python", 40, "Extracting Python...", false);
- extract_zip(&zip_path, &python_dir)?;
-
- // Enable site-packages
- let pth_file = python_dir.join("python312._pth");
- if pth_file.exists() {
- let mut content = fs::read_to_string(&pth_file)
- .map_err(|e| format!("Failed to read _pth: {}", e))?;
- content = content.replace("#import site", "import site");
- content.push_str("\nLib\\site-packages\n");
- fs::write(&pth_file, content)
- .map_err(|e| format!("Failed to write _pth: {}", e))?;
- }
+ cmd.creation_flags(CREATE_NO_WINDOW);
- fs::remove_file(zip_path).ok();
+ let output = cmd.output().map_err(|e| format!("Download failed: {}", e))?;
+ if !output.status.success() {
+ return Err(format!("Download failed: {}", String::from_utf8_lossy(&output.stderr)));
}
- #[cfg(not(target_os = "windows"))]
- {
- // macOS/Linux: Download standalone Python
- let url = if cfg!(target_os = "macos") {
- if cfg!(target_arch = "aarch64") {
- "https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.12.7+20241016-aarch64-apple-darwin-install_only_stripped.tar.gz"
- } else {
- "https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.12.7+20241016-x86_64-apple-darwin-install_only_stripped.tar.gz"
- }
- } else {
- if cfg!(target_arch = "aarch64") {
- "https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.12.7+20241016-aarch64-unknown-linux-gnu-install_only_stripped.tar.gz"
- } else {
- "https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.12.7+20241016-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz"
- }
- };
+ emit_progress(app, "python", 60, "Extracting Python...", false);
- let tar_path = temp_dir.join("python.tar.gz");
- download_file(url, &tar_path, app, "python").await?;
+ // Extract
+ let mut cmd = Command::new("powershell");
+ cmd.args(&[
+ "-Command",
+ &format!("Expand-Archive -Path '{}' -DestinationPath '{}' -Force", zip_path.display(), python_dir.display())
+ ]);
+ #[cfg(target_os = "windows")]
+ cmd.creation_flags(CREATE_NO_WINDOW);
- emit_progress(app, "python", 40, "Extracting Python...", false);
- Command::new("tar")
- .args(&["-xzf", tar_path.to_str().unwrap(), "-C", python_dir.to_str().unwrap(), "--strip-components=1"])
- .output()
- .map_err(|e| format!("Failed to extract: {}", e))?;
+ let output = cmd.output().map_err(|e| format!("Extract failed: {}", e))?;
+ if !output.status.success() {
+ return Err(format!("Extract failed: {}", String::from_utf8_lossy(&output.stderr)));
+ }
- let python_exe = python_dir.join("bin/python3");
- if python_exe.exists() {
- Command::new("chmod").args(&["+x", python_exe.to_str().unwrap()]).output().ok();
- }
+ // Delete zip
+ let _ = std::fs::remove_file(&zip_path);
- fs::remove_file(tar_path).ok();
+ // Enable pip by modifying python312._pth
+ let pth_file = python_dir.join("python312._pth");
+ if pth_file.exists() {
+ if let Ok(content) = std::fs::read_to_string(&pth_file) {
+ let new_content = content.replace("#import site", "import site");
+ let _ = std::fs::write(&pth_file, new_content);
+ }
+ } else {
+ // Create _pth file if it doesn't exist
+ let pth_content = "python312.zip\n.\n\nimport site\n";
+ let _ = std::fs::write(&pth_file, pth_content);
}
- emit_progress(app, "python", 60, "Python extracted", false);
+ // Download and install pip
+ emit_progress(app, "python", 80, "Installing pip...", false);
- // Verify
- let (installed, version) = check_python(install_dir);
- if !installed {
- return Err("Python verification failed".to_string());
- }
+ let get_pip_url = "https://bootstrap.pypa.io/get-pip.py";
+ let get_pip_path = python_dir.join("get-pip.py");
- emit_progress(app, "python", 70, &format!("Python {} verified", version.unwrap_or_default()), false);
- Ok(())
-}
+ let mut cmd = Command::new("powershell");
+ cmd.args(&[
+ "-Command",
+ &format!("Invoke-WebRequest -Uri '{}' -OutFile '{}'", get_pip_url, get_pip_path.display())
+ ]);
+ #[cfg(target_os = "windows")]
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ cmd.output().map_err(|e| format!("Failed to download get-pip.py: {}", e))?;
-/// Extract ZIP (Windows only)
-#[cfg(target_os = "windows")]
-fn extract_zip(zip_path: &PathBuf, dest_dir: &PathBuf) -> Result<(), String> {
- use zip::ZipArchive;
- use std::io::copy;
-
- let file = fs::File::open(zip_path)
- .map_err(|e| format!("Failed to open ZIP: {}", e))?;
- let mut archive = ZipArchive::new(file)
- .map_err(|e| format!("Failed to read ZIP: {}", e))?;
-
- for i in 0..archive.len() {
- let mut file = archive.by_index(i)
- .map_err(|e| format!("Failed to read entry: {}", e))?;
- let outpath = match file.enclosed_name() {
- Some(path) => dest_dir.join(path),
- None => continue,
- };
+ let python_exe = python_dir.join("python.exe");
+ let mut cmd = Command::new(&python_exe);
+ cmd.arg(get_pip_path.to_str().unwrap());
+ #[cfg(target_os = "windows")]
+ cmd.creation_flags(CREATE_NO_WINDOW);
- if file.name().ends_with('/') {
- fs::create_dir_all(&outpath)
- .map_err(|e| format!("Failed to create dir: {}", e))?;
- } else {
- if let Some(p) = outpath.parent() {
- fs::create_dir_all(p)
- .map_err(|e| format!("Failed to create parent: {}", e))?;
- }
- let mut outfile = fs::File::create(&outpath)
- .map_err(|e| format!("Failed to create file: {}", e))?;
- copy(&mut file, &mut outfile)
- .map_err(|e| format!("Failed to extract: {}", e))?;
- }
- }
- Ok(())
-}
+ let output = cmd.output().map_err(|e| format!("Failed to install pip: {}", e))?;
-/// Detect CPU features to determine which Bun build to use
-#[cfg(target_os = "linux")]
-fn detect_cpu_features() -> bool {
- // Check if CPU supports AVX2 (required for standard Bun build)
- // Returns true if AVX2 is supported, false otherwise
-
- // Method 1: Check /proc/cpuinfo
- if let Ok(cpuinfo) = fs::read_to_string("/proc/cpuinfo") {
- // Look for avx2 in the flags line
- for line in cpuinfo.lines() {
- if line.starts_with("flags") || line.starts_with("Features") {
- let has_avx2 = line.contains("avx2");
- eprintln!("[SETUP] [bun] CPU flags found: {}", if has_avx2 { "AVX2 supported" } else { "AVX2 NOT supported" });
- return has_avx2;
- }
- }
- }
+ eprintln!("[SETUP] [Python] pip install stdout: {}", String::from_utf8_lossy(&output.stdout));
+ eprintln!("[SETUP] [Python] pip install stderr: {}", String::from_utf8_lossy(&output.stderr));
- // Method 2: Try using lscpu command
- if let Ok(output) = Command::new("lscpu").output() {
- let lscpu_output = String::from_utf8_lossy(&output.stdout);
- if lscpu_output.contains("avx2") {
- eprintln!("[SETUP] [bun] CPU check (lscpu): AVX2 supported");
- return true;
- }
+ if !output.status.success() {
+ return Err(format!("Pip install failed: {}", String::from_utf8_lossy(&output.stderr)));
}
- eprintln!("[SETUP] [bun] CPU check: Could not detect AVX2, using baseline build for safety");
- false
+ let _ = std::fs::remove_file(&get_pip_path);
+
+ emit_progress(app, "python", 100, "Python installed", false);
+ Ok(())
}
-/// Install Bun (all platforms)
+/// Install Bun
async fn install_bun(app: &AppHandle, install_dir: &PathBuf) -> Result<(), String> {
emit_progress(app, "bun", 0, "Installing Bun...", false);
let bun_dir = install_dir.join("bun");
- fs::create_dir_all(&bun_dir)
- .map_err(|e| format!("Failed to create bun dir: {}", e))?;
+ std::fs::create_dir_all(&bun_dir)
+ .map_err(|e| format!("Failed to create Bun dir: {}", e))?;
- let temp_dir = std::env::temp_dir();
+ if cfg!(target_os = "windows") {
+ let download_url = format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-windows-x64.zip", BUN_VERSION);
+ let zip_path = bun_dir.join("bun.zip");
- #[cfg(target_os = "windows")]
- {
- let url = if cfg!(target_arch = "aarch64") {
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-windows-aarch64.zip", BUN_VERSION)
- } else {
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-windows-x64.zip", BUN_VERSION)
- };
+ emit_progress(app, "bun", 30, "Downloading Bun...", false);
- let zip_path = temp_dir.join("bun.zip");
- download_file(&url, &zip_path, app, "bun").await?;
-
- emit_progress(app, "bun", 40, "Extracting Bun...", false);
- let temp_extract = temp_dir.join("bun_temp");
- fs::create_dir_all(&temp_extract).ok();
- extract_zip(&zip_path, &temp_extract)?;
-
- // Move bun.exe from nested folder to bun_dir
- if let Ok(entries) = fs::read_dir(&temp_extract) {
- for entry in entries.flatten() {
- let bun_exe = entry.path().join("bun.exe");
- if bun_exe.exists() {
- fs::copy(&bun_exe, bun_dir.join("bun.exe"))
- .map_err(|e| format!("Failed to copy bun.exe: {}", e))?;
- break;
- }
- }
- }
+ let mut cmd = Command::new("powershell");
+ cmd.args(&[
+ "-Command",
+ &format!("Invoke-WebRequest -Uri '{}' -OutFile '{}'", download_url, zip_path.display())
+ ]);
+ cmd.creation_flags(CREATE_NO_WINDOW);
- fs::remove_file(zip_path).ok();
- fs::remove_dir_all(temp_extract).ok();
- }
-
- #[cfg(not(target_os = "windows"))]
- {
- // Determine the best Bun build URL based on platform and architecture
- let urls = if cfg!(target_os = "macos") {
- if cfg!(target_arch = "aarch64") {
- vec![format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-darwin-aarch64.zip", BUN_VERSION)]
- } else {
- vec![format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-darwin-x64.zip", BUN_VERSION)]
- }
- } else {
- // Linux
- if cfg!(target_arch = "aarch64") {
- vec![format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-aarch64.zip", BUN_VERSION)]
- } else {
- // For x64 Linux, detect CPU features and choose appropriate build
- #[cfg(target_os = "linux")]
- {
- let has_avx2 = detect_cpu_features();
-
- if has_avx2 {
- // CPU supports AVX2, use standard build (faster) with baseline as fallback
- eprintln!("[SETUP] [bun] CPU supports AVX2, using optimized build");
- vec![
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-x64.zip", BUN_VERSION),
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-x64-baseline.zip", BUN_VERSION),
- ]
- } else {
- // CPU doesn't support AVX2 or detection failed, use baseline build
- eprintln!("[SETUP] [bun] Using baseline build for compatibility");
- vec![
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-x64-baseline.zip", BUN_VERSION),
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-x64.zip", BUN_VERSION),
- ]
- }
- }
-
- #[cfg(not(target_os = "linux"))]
- {
- // Fallback for other Unix-like systems
- vec![
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-x64-baseline.zip", BUN_VERSION),
- format!("https://github.com/oven-sh/bun/releases/download/bun-v{}/bun-linux-x64.zip", BUN_VERSION),
- ]
- }
- }
- };
-
- let zip_path = temp_dir.join("bun.zip");
- let mut download_success = false;
-
- // Try each URL until one works
- for (idx, url) in urls.iter().enumerate() {
- eprintln!("[SETUP] [bun] Attempting download from: {}", url);
- match download_file(&url, &zip_path, app, "bun").await {
- Ok(_) => {
- eprintln!("[SETUP] [bun] Downloaded successfully to: {}", zip_path.display());
- download_success = true;
- break;
- }
- Err(e) => {
- eprintln!("[SETUP] [bun] Download failed (attempt {}/{}): {}", idx + 1, urls.len(), e);
- if idx < urls.len() - 1 {
- eprintln!("[SETUP] [bun] Trying alternative URL...");
- }
- }
- }
- }
-
- if !download_success {
- return Err("Failed to download Bun from any available source".to_string());
+ let output = cmd.output().map_err(|e| format!("Download failed: {}", e))?;
+ if !output.status.success() {
+ return Err(format!("Download failed: {}", String::from_utf8_lossy(&output.stderr)));
}
- emit_progress(app, "bun", 40, "Extracting Bun...", false);
-
- let temp_extract = temp_dir.join("bun_temp");
- fs::create_dir_all(&temp_extract)
- .map_err(|e| format!("Failed to create temp extract dir: {}", e))?;
-
- eprintln!("[SETUP] [bun] Extracting to: {}", temp_extract.display());
-
- // Check if unzip is available
- let unzip_check = Command::new("which").arg("unzip").output();
- if unzip_check.is_err() || !unzip_check.unwrap().status.success() {
- eprintln!("[SETUP] [bun] WARNING: unzip command not found, trying fallback");
- // Try using tar if unzip is not available (some minimal Linux systems)
- let tar_result = Command::new("tar")
- .args(&["-xf", zip_path.to_str().unwrap(), "-C", temp_extract.to_str().unwrap()])
- .output();
-
- if tar_result.is_err() {
- return Err("Neither unzip nor tar available for extraction".to_string());
- }
- } else {
- let output = Command::new("unzip")
- .args(&["-o", zip_path.to_str().unwrap(), "-d", temp_extract.to_str().unwrap()])
- .output()
- .map_err(|e| format!("Failed to run unzip: {}", e))?;
-
- if !output.status.success() {
- let stderr = String::from_utf8_lossy(&output.stderr);
- eprintln!("[SETUP] [bun] Unzip stderr: {}", stderr);
- return Err(format!("Unzip failed: {}", stderr));
- }
- }
+ emit_progress(app, "bun", 70, "Extracting Bun...", false);
- eprintln!("[SETUP] [bun] Extraction complete, searching for executable...");
-
- // Find and move bun executable from nested folder
- fn find_bun_executable(dir: &PathBuf, depth: usize) -> Option<PathBuf> {
- eprintln!("[SETUP] [bun] Searching in: {} (depth: {})", dir.display(), depth);
-
- if depth > 5 {
- return None; // Prevent infinite recursion
- }
-
- if let Ok(entries) = fs::read_dir(dir) {
- for entry in entries.flatten() {
- let path = entry.path();
- eprintln!("[SETUP] [bun] Found: {}", path.display());
-
- if path.is_file() {
- if let Some(filename) = path.file_name() {
- if filename == "bun" {
- eprintln!("[SETUP] [bun] ✓ Found bun executable at: {}", path.display());
- return Some(path);
- }
- }
- } else if path.is_dir() {
- if let Some(found) = find_bun_executable(&path, depth + 1) {
- return Some(found);
- }
- }
- }
- }
- None
- }
+ let mut cmd = Command::new("powershell");
+ cmd.args(&[
+ "-Command",
+ &format!("Expand-Archive -Path '{}' -DestinationPath '{}' -Force", zip_path.display(), bun_dir.display())
+ ]);
+ cmd.creation_flags(CREATE_NO_WINDOW);
- if let Some(bun_file) = find_bun_executable(&temp_extract, 0) {
- let bun_dest = bun_dir.join("bun");
- eprintln!("[SETUP] [bun] Copying from {} to {}", bun_file.display(), bun_dest.display());
-
- fs::copy(&bun_file, &bun_dest)
- .map_err(|e| format!("Failed to copy bun from {} to {}: {}", bun_file.display(), bun_dest.display(), e))?;
-
- eprintln!("[SETUP] [bun] Setting executable permissions...");
- let chmod_output = Command::new("chmod")
- .args(&["+x", bun_dest.to_str().unwrap()])
- .output();
-
- match chmod_output {
- Ok(output) => {
- if !output.status.success() {
- let stderr = String::from_utf8_lossy(&output.stderr);
- eprintln!("[SETUP] [bun] chmod stderr: {}", stderr);
- } else {
- eprintln!("[SETUP] [bun] ✓ Executable permissions set");
- }
- }
- Err(e) => {
- eprintln!("[SETUP] [bun] chmod error: {}", e);
- }
- }
- } else {
- // List what we found in temp_extract for debugging
- eprintln!("[SETUP] [bun] ERROR: Bun executable not found. Contents of temp_extract:");
- if let Ok(entries) = fs::read_dir(&temp_extract) {
- for entry in entries.flatten() {
- eprintln!("[SETUP] [bun] - {}", entry.path().display());
- }
- }
- return Err("Bun executable not found in archive".to_string());
+ let output = cmd.output().map_err(|e| format!("Extract failed: {}", e))?;
+ if !output.status.success() {
+ return Err(format!("Extract failed: {}", String::from_utf8_lossy(&output.stderr)));
}
- fs::remove_file(zip_path).ok();
- fs::remove_dir_all(temp_extract).ok();
- }
+ let _ = std::fs::remove_file(&zip_path);
- emit_progress(app, "bun", 60, "Bun extracted", false);
+ // Move bun.exe from nested folder to bun/ root
+ let nested_bun = bun_dir.join("bun-windows-x64/bun.exe");
+ let target_bun = bun_dir.join("bun.exe");
- // Verify
- eprintln!("[SETUP] [bun] Verifying installation...");
- let bun_path = if cfg!(target_os = "windows") {
- install_dir.join("bun/bun.exe")
- } else {
- install_dir.join("bun/bun")
- };
- eprintln!("[SETUP] [bun] Checking path: {}", bun_path.display());
- eprintln!("[SETUP] [bun] File exists: {}", bun_path.exists());
-
- let (installed, version) = check_bun(install_dir);
- if !installed {
- eprintln!("[SETUP] [bun] ERROR: Verification failed!");
- eprintln!("[SETUP] [bun] Expected path: {}", bun_path.display());
-
- // Try running bun directly to see what error we get
- if bun_path.exists() {
- eprintln!("[SETUP] [bun] File exists but verification failed. Trying to run it...");
- let test_cmd = Command::new(&bun_path).arg("--version").output();
- let mut is_sigill = false;
-
- match test_cmd {
- Ok(output) => {
- let status_str = format!("{}", output.status);
- eprintln!("[SETUP] [bun] Exit code: {}", status_str);
- eprintln!("[SETUP] [bun] Stdout: {}", String::from_utf8_lossy(&output.stdout));
- eprintln!("[SETUP] [bun] Stderr: {}", String::from_utf8_lossy(&output.stderr));
-
- // Check if it's a SIGILL error (illegal instruction)
- if status_str.contains("SIGILL") || status_str.contains("signal: 4") {
- eprintln!("[SETUP] [bun] SIGILL detected - binary incompatible with CPU");
- is_sigill = true;
- }
- }
- Err(e) => {
- eprintln!("[SETUP] [bun] Failed to execute: {}", e);
- }
- }
-
- // Check file permissions
- #[cfg(not(target_os = "windows"))]
- {
- let metadata = std::fs::metadata(&bun_path);
- if let Ok(meta) = metadata {
- use std::os::unix::fs::PermissionsExt;
- let permissions = meta.permissions();
- eprintln!("[SETUP] [bun] File permissions: {:o}", permissions.mode());
- }
- }
-
- if is_sigill {
- return Err("Bun verification failed - CPU incompatibility detected. The downloaded binary requires newer CPU instructions (AVX2) that your system doesn't support. This usually happens in virtualized environments. Please report this issue.".to_string());
- }
+ if nested_bun.exists() && !target_bun.exists() {
+ std::fs::copy(&nested_bun, &target_bun)
+ .map_err(|e| format!("Failed to copy bun.exe: {}", e))?;
+ // Clean up nested directory
+ let _ = std::fs::remove_dir_all(bun_dir.join("bun-windows-x64"));
}
-
- return Err("Bun verification failed - executable exists but cannot run".to_string());
+ } else {
+ return Err("Auto-install only supported on Windows. Install Bun manually.".to_string());
}
- eprintln!("[SETUP] [bun] ✓ Verification successful: {}", version.as_ref().unwrap_or(&"unknown".to_string()));
- emit_progress(app, "bun", 70, &format!("Bun {} verified", version.unwrap_or_default()), false);
+ emit_progress(app, "bun", 100, "Bun installed", false);
Ok(())
}
-/// Install UV binary (all platforms)
+/// Install UV package manager
async fn install_uv(app: &AppHandle, install_dir: &PathBuf) -> Result<(), String> {
emit_progress(app, "uv", 0, "Installing UV package manager...", false);
- let temp_dir = std::env::temp_dir();
+ let pip_exe = if cfg!(target_os = "windows") {
+ install_dir.join("python/Scripts/pip.exe")
+ } else {
+ install_dir.join("python/bin/pip")
+ };
+ let mut cmd = Command::new(&pip_exe);
+ cmd.args(&["install", "uv"]);
#[cfg(target_os = "windows")]
- {
- let url = if cfg!(target_arch = "aarch64") {
- format!("https://github.com/astral-sh/uv/releases/download/{}/uv-aarch64-pc-windows-msvc.zip", UV_VERSION)
- } else {
- format!("https://github.com/astral-sh/uv/releases/download/{}/uv-x86_64-pc-windows-msvc.zip", UV_VERSION)
- };
-
- let zip_path = temp_dir.join("uv.zip");
- download_file(&url, &zip_path, app, "uv").await?;
-
- emit_progress(app, "uv", 40, "Extracting UV...", false);
-
- let scripts_dir = install_dir.join("python/Scripts");
- fs::create_dir_all(&scripts_dir)
- .map_err(|e| format!("Failed to create Scripts dir: {}", e))?;
-
- use zip::ZipArchive;
- use std::io::copy;
-
- let file = fs::File::open(&zip_path)
- .map_err(|e| format!("Failed to open uv ZIP: {}", e))?;
- let mut archive = ZipArchive::new(file)
- .map_err(|e| format!("Failed to read uv ZIP: {}", e))?;
-
- let mut found = false;
- for i in 0..archive.len() {
- let mut zip_file = archive.by_index(i)
- .map_err(|e| format!("Failed to read ZIP entry: {}", e))?;
-
- if zip_file.name().ends_with("uv.exe") {
- let uv_dest = scripts_dir.join("uv.exe");
- let mut dest_file = fs::File::create(&uv_dest)
- .map_err(|e| format!("Failed to create uv.exe: {}", e))?;
- copy(&mut zip_file, &mut dest_file)
- .map_err(|e| format!("Failed to extract uv.exe: {}", e))?;
- found = true;
- break;
- }
- }
-
- if !found {
- return Err("uv.exe not found in archive".to_string());
- }
-
- fs::remove_file(zip_path).ok();
- }
-
- #[cfg(not(target_os = "windows"))]
- {
- let url = if cfg!(target_os = "macos") {
- if cfg!(target_arch = "aarch64") {
- format!("https://github.com/astral-sh/uv/releases/download/{}/uv-aarch64-apple-darwin.tar.gz", UV_VERSION)
- } else {
- format!("https://github.com/astral-sh/uv/releases/download/{}/uv-x86_64-apple-darwin.tar.gz", UV_VERSION)
- }
- } else {
- if cfg!(target_arch = "aarch64") {
- format!("https://github.com/astral-sh/uv/releases/download/{}/uv-aarch64-unknown-linux-gnu.tar.gz", UV_VERSION)
- } else {
- format!("https://github.com/astral-sh/uv/releases/download/{}/uv-x86_64-unknown-linux-gnu.tar.gz", UV_VERSION)
- }
- };
-
- let tar_path = temp_dir.join("uv.tar.gz");
- download_file(&url, &tar_path, app, "uv").await?;
-
- emit_progress(app, "uv", 40, "Extracting UV...", false);
-
- let bin_dir = install_dir.join("python/bin");
- fs::create_dir_all(&bin_dir)
- .map_err(|e| format!("Failed to create bin dir: {}", e))?;
-
- let temp_extract_dir = temp_dir.join("uv_extract");
- fs::create_dir_all(&temp_extract_dir)
- .map_err(|e| format!("Failed to create temp dir: {}", e))?;
-
- Command::new("tar")
- .args(&["-xzf", tar_path.to_str().unwrap(), "-C", temp_extract_dir.to_str().unwrap()])
- .output()
- .map_err(|e| format!("Failed to extract uv: {}", e))?;
-
- let mut found = false;
- if let Ok(entries) = fs::read_dir(&temp_extract_dir) {
- for entry in entries.flatten() {
- let uv_file = entry.path().join("uv");
- if uv_file.exists() {
- let uv_dest = bin_dir.join("uv");
- fs::copy(&uv_file, &uv_dest)
- .map_err(|e| format!("Failed to copy uv: {}", e))?;
- Command::new("chmod").args(&["+x", uv_dest.to_str().unwrap()]).output().ok();
- found = true;
- break;
- }
- }
- }
-
- if !found {
- return Err("uv binary not found in archive".to_string());
- }
+ cmd.creation_flags(CREATE_NO_WINDOW);
- fs::remove_file(tar_path).ok();
- fs::remove_dir_all(temp_extract_dir).ok();
- }
+ eprintln!("[SETUP] Installing UV: {:?}", cmd);
+ let output = cmd.output().map_err(|e| format!("Failed to install UV: {}", e))?;
- emit_progress(app, "uv", 60, "UV extracted", false);
+ eprintln!("[SETUP] UV stdout: {}", String::from_utf8_lossy(&output.stdout));
+ eprintln!("[SETUP] UV stderr: {}", String::from_utf8_lossy(&output.stderr));
- // Verify
- if !check_uv(install_dir) {
- return Err("UV verification failed".to_string());
+ if !output.status.success() {
+ return Err(format!("UV installation failed: {}", String::from_utf8_lossy(&output.stderr)));
}
- emit_progress(app, "uv", 70, "UV verified", false);
+ emit_progress(app, "uv", 100, "UV installed", false);
Ok(())
}
-/// Install NumPy 1.x venv packages
-async fn install_packages_numpy1(app: &AppHandle, install_dir: &PathBuf) -> Result<(), String> {
- emit_progress(app, "packages-np1", 0, "Installing NumPy 1.x packages...", false);
+/// Create virtual environment using UV
+async fn create_venv(app: &AppHandle, install_dir: &PathBuf, venv_name: &str) -> Result<(), String> {
+ emit_progress(app, "venv", 0, &format!("Creating {}...", venv_name), false);
let python_exe = if cfg!(target_os = "windows") {
install_dir.join("python/python.exe")
@@ -783,61 +359,45 @@ async fn install_packages_numpy1(app: &AppHandle, install_dir: &PathBuf) -> Resu
install_dir.join("python/bin/uv")
};
- let venv_path = install_dir.join("venv-numpy1");
- let requirements_path = app.path()
- .resolve("resources/requirements-numpy1.txt", tauri::path::BaseDirectory::Resource)
- .map_err(|e| format!("Failed to find requirements-numpy1.txt: {}", e))?;
-
- eprintln!("[SETUP] [NumPy1] Creating venv at: {}", venv_path.display());
- emit_progress(app, "packages-np1", 10, "Creating venv...", false);
+ let venv_path = install_dir.join(venv_name);
- // Create venv
let mut cmd = Command::new(&uv_exe);
- cmd.args(&["venv", "--python", python_exe.to_str().unwrap(), venv_path.to_str().unwrap()]);
+ cmd.args(&[
+ "venv",
+ venv_path.to_str().unwrap(),
+ "--python", python_exe.to_str().unwrap()
+ ]);
#[cfg(target_os = "windows")]
cmd.creation_flags(CREATE_NO_WINDOW);
- let output = cmd.output().map_err(|e| format!("Failed to create venv: {}", e))?;
- if !output.status.success() {
- return Err(format!("venv creation failed: {}", String::from_utf8_lossy(&output.stderr)));
- }
-
- emit_progress(app, "packages-np1", 30, "Installing packages...", false);
-
- // Install packages
- let venv_python = if cfg!(target_os = "windows") {
- venv_path.join("Scripts/python.exe")
- } else {
- venv_path.join("bin/python3")
- };
-
- let mut cmd = Command::new(&uv_exe);
- cmd.args(&["pip", "install", "--python", venv_python.to_str().unwrap(), "-r", requirements_path.to_str().unwrap()]);
- #[cfg(target_os = "windows")]
- cmd.creation_flags(CREATE_NO_WINDOW);
+ eprintln!("[SETUP] Creating venv: {:?}", cmd);
+ let output = cmd.output().map_err(|e| format!("Failed to create {}: {}", venv_name, e))?;
- eprintln!("[SETUP] [NumPy1] Running: {:?}", cmd);
- let output = cmd.output().map_err(|e| format!("Failed to install packages: {}", e))?;
-
- eprintln!("[SETUP] [NumPy1] stdout: {}", String::from_utf8_lossy(&output.stdout));
- eprintln!("[SETUP] [NumPy1] stderr: {}", String::from_utf8_lossy(&output.stderr));
+ eprintln!("[SETUP] Venv stdout: {}", String::from_utf8_lossy(&output.stdout));
+ eprintln!("[SETUP] Venv stderr: {}", String::from_utf8_lossy(&output.stderr));
if !output.status.success() {
- return Err(format!("NumPy 1.x installation failed: {}", String::from_utf8_lossy(&output.stderr)));
+ return Err(format!("{} creation failed: {}", venv_name, String::from_utf8_lossy(&output.stderr)));
}
- emit_progress(app, "packages-np1", 100, "NumPy 1.x complete", false);
+ emit_progress(app, "venv", 100, &format!("{} created", venv_name), false);
Ok(())
}
-/// Install NumPy 2.x venv packages
-async fn install_packages_numpy2(app: &AppHandle, install_dir: &PathBuf) -> Result<(), String> {
- emit_progress(app, "packages-np2", 0, "Installing NumPy 2.x packages...", false);
+/// Install Python packages in a specific venv using UV
+async fn install_packages_in_venv(
+ app: &AppHandle,
+ install_dir: &PathBuf,
+ venv_name: &str,
+ requirements_file: &str,
+ progress_label: &str
+) -> Result<(), String> {
+ emit_progress(app, "packages", 0, &format!("Installing {} packages...", progress_label), false);
- let python_exe = if cfg!(target_os = "windows") {
- install_dir.join("python/python.exe")
+ let venv_python = if cfg!(target_os = "windows") {
+ install_dir.join(format!("{}/Scripts/python.exe", venv_name))
} else {
- install_dir.join("python/bin/python3")
+ install_dir.join(format!("{}/bin/python3", venv_name))
};
let uv_exe = if cfg!(target_os = "windows") {
@@ -846,50 +406,32 @@ async fn install_packages_numpy2(app: &AppHandle, install_dir: &PathBuf) -> Resu
install_dir.join("python/bin/uv")
};
- let venv_path = install_dir.join("venv-numpy2");
let requirements_path = app.path()
- .resolve("resources/requirements-numpy2.txt", tauri::path::BaseDirectory::Resource)
- .map_err(|e| format!("Failed to find requirements-numpy2.txt: {}", e))?;
-
- eprintln!("[SETUP] [NumPy2] Creating venv at: {}", venv_path.display());
- emit_progress(app, "packages-np2", 10, "Creating venv...", false);
-
- // Create venv
- let mut cmd = Command::new(&uv_exe);
- cmd.args(&["venv", "--python", python_exe.to_str().unwrap(), venv_path.to_str().unwrap()]);
- #[cfg(target_os = "windows")]
- cmd.creation_flags(CREATE_NO_WINDOW);
-
- let output = cmd.output().map_err(|e| format!("Failed to create venv: {}", e))?;
- if !output.status.success() {
- return Err(format!("venv creation failed: {}", String::from_utf8_lossy(&output.stderr)));
- }
-
- emit_progress(app, "packages-np2", 30, "Installing packages...", false);
+ .resolve(&format!("resources/{}", requirements_file), tauri::path::BaseDirectory::Resource)
+ .map_err(|e| format!("Failed to find {}: {}", requirements_file, e))?;
- // Install packages
- let venv_python = if cfg!(target_os = "windows") {
- venv_path.join("Scripts/python.exe")
- } else {
- venv_path.join("bin/python3")
- };
+ emit_progress(app, "packages", 20, &format!("Installing {} packages with UV...", progress_label), false);
let mut cmd = Command::new(&uv_exe);
- cmd.args(&["pip", "install", "--python", venv_python.to_str().unwrap(), "-r", requirements_path.to_str().unwrap()]);
+ cmd.args(&[
+ "pip", "install",
+ "--python", venv_python.to_str().unwrap(),
+ "-r", requirements_path.to_str().unwrap()
+ ]);
#[cfg(target_os = "windows")]
cmd.creation_flags(CREATE_NO_WINDOW);
- eprintln!("[SETUP] [NumPy2] Running: {:?}", cmd);
- let output = cmd.output().map_err(|e| format!("Failed to install packages: {}", e))?;
+ eprintln!("[SETUP] Installing {} packages: {:?}", progress_label, cmd);
+ let output = cmd.output().map_err(|e| format!("Failed to install {} packages: {}", progress_label, e))?;
- eprintln!("[SETUP] [NumPy2] stdout: {}", String::from_utf8_lossy(&output.stdout));
- eprintln!("[SETUP] [NumPy2] stderr: {}", String::from_utf8_lossy(&output.stderr));
+ eprintln!("[SETUP] {} stdout: {}", progress_label, String::from_utf8_lossy(&output.stdout));
+ eprintln!("[SETUP] {} stderr: {}", progress_label, String::from_utf8_lossy(&output.stderr));
if !output.status.success() {
- return Err(format!("NumPy 2.x installation failed: {}", String::from_utf8_lossy(&output.stderr)));
+ return Err(format!("{} package installation failed: {}", progress_label, String::from_utf8_lossy(&output.stderr)));
}
- emit_progress(app, "packages-np2", 100, "NumPy 2.x complete", false);
+ emit_progress(app, "packages", 100, &format!("{} packages installed", progress_label), false);
Ok(())
}
@@ -900,91 +442,97 @@ pub fn check_setup_status(app: AppHandle) -> Result<SetupStatus, String> {
let (python_installed, _) = check_python(&install_dir);
let (bun_installed, _) = check_bun(&install_dir);
- let uv_installed = check_uv(&install_dir);
- let packages_numpy1_installed = check_packages_numpy1(&install_dir);
- let packages_numpy2_installed = check_packages_numpy2(&install_dir);
- let packages_installed = packages_numpy1_installed && packages_numpy2_installed;
+ let packages_installed = check_packages(&install_dir);
- let needs_setup = !python_installed || !bun_installed || !uv_installed || !packages_numpy1_installed || !packages_numpy2_installed;
+ let needs_setup = !python_installed || !bun_installed || !packages_installed;
Ok(SetupStatus {
python_installed,
bun_installed,
- uv_installed,
packages_installed,
- packages_numpy1_installed,
- packages_numpy2_installed,
needs_setup,
})
}
/// Run complete setup
#[tauri::command]
-pub async fn run_setup(app: AppHandle) -> Result<(), String> {
- // Prevent concurrent setup runs
+pub async fn run_setup(app: AppHandle) -> Result<String, String> {
+ // Check if setup is already running
{
- let mut running = SETUP_RUNNING.lock().unwrap();
- if *running {
+ let mut lock = SETUP_RUNNING.lock().unwrap();
+ if *lock {
return Err("Setup already running".to_string());
}
- *running = true;
- }
+ *lock = true;
+ } // Lock dropped here
- let result = run_setup_internal(app).await;
+ let result = async {
+ let install_dir = get_install_dir(&app)?;
+ std::fs::create_dir_all(&install_dir)
+ .map_err(|e| format!("Failed to create install dir: {}", e))?;
- // Release lock
- *SETUP_RUNNING.lock().unwrap() = false;
- result
-}
-
-async fn run_setup_internal(app: AppHandle) -> Result<(), String> {
- let install_dir = get_install_dir(&app)?;
- eprintln!("[SETUP] Install directory: {}", install_dir.display());
- eprintln!("[SETUP] Dev mode: {}", is_dev_mode());
+ eprintln!("[SETUP] Install directory: {}", install_dir.display());
+ emit_progress(&app, "init", 0, "Starting setup...", false);
- fs::create_dir_all(&install_dir)
- .map_err(|e| format!("Failed to create install dir: {}", e))?;
-
- let status = check_setup_status(app.clone())?;
-
- // Step 1: Install Python
- if !status.python_installed {
- install_python(&app, &install_dir).await?;
- emit_progress(&app, "python", 100, "Python complete", false);
- } else {
- emit_progress(&app, "python", 100, "Python already installed", false);
- }
+ // Python
+ let (python_installed, python_version) = check_python(&install_dir);
+ if !python_installed {
+ install_python(&app, &install_dir).await?;
+ } else {
+ eprintln!("[SETUP] Python already installed: {}", python_version.unwrap_or_default());
+ emit_progress(&app, "python", 100, "Python already installed", false);
+ }
- // Step 2: Install Bun
- if !status.bun_installed {
- install_bun(&app, &install_dir).await?;
- emit_progress(&app, "bun", 100, "Bun complete", false);
- } else {
- emit_progress(&app, "bun", 100, "Bun already installed", false);
- }
+ // Bun
+ let (bun_installed, bun_version) = check_bun(&install_dir);
+ if !bun_installed {
+ install_bun(&app, &install_dir).await?;
+ } else {
+ eprintln!("[SETUP] Bun already installed: {}", bun_version.unwrap_or_default());
+ emit_progress(&app, "bun", 100, "Bun already installed", false);
+ }
- // Step 3: Install UV
- if !status.uv_installed {
+ // UV (fast package manager)
install_uv(&app, &install_dir).await?;
- emit_progress(&app, "uv", 100, "UV complete", false);
- } else {
- emit_progress(&app, "uv", 100, "UV already installed", false);
- }
- // Step 4: Install NumPy 1.x packages
- if !status.packages_numpy1_installed {
- install_packages_numpy1(&app, &install_dir).await?;
- } else {
- emit_progress(&app, "packages-np1", 100, "NumPy 1.x already installed", false);
- }
+ // Create venvs and install packages
+ if !check_packages(&install_dir) {
+ // Create venv-numpy1 for NumPy 1.x libraries
+ emit_progress(&app, "venv", 0, "Creating NumPy 1.x environment...", false);
+ create_venv(&app, &install_dir, "venv-numpy1").await?;
+
+ // Install numpy1 packages
+ install_packages_in_venv(
+ &app,
+ &install_dir,
+ "venv-numpy1",
+ "requirements-numpy1.txt",
+ "NumPy 1.x"
+ ).await?;
+
+ // Create venv-numpy2 for NumPy 2.x libraries
+ emit_progress(&app, "venv", 50, "Creating NumPy 2.x environment...", false);
+ create_venv(&app, &install_dir, "venv-numpy2").await?;
+
+ // Install numpy2 packages
+ install_packages_in_venv(
+ &app,
+ &install_dir,
+ "venv-numpy2",
+ "requirements-numpy2.txt",
+ "NumPy 2.x"
+ ).await?;
+ } else {
+ eprintln!("[SETUP] Packages already installed in both venvs");
+ emit_progress(&app, "packages", 100, "Packages already installed", false);
+ }
- // Step 5: Install NumPy 2.x packages
- if !status.packages_numpy2_installed {
- install_packages_numpy2(&app, &install_dir).await?;
- } else {
- emit_progress(&app, "packages-np2", 100, "NumPy 2.x already installed", false);
- }
+ emit_progress(&app, "complete", 100, "Setup complete!", false);
+ Ok("Setup complete".to_string())
+ }.await;
- emit_progress(&app, "complete", 100, "Setup complete! Both environments ready", false);
- Ok(())
+ let mut lock = SETUP_RUNNING.lock().unwrap();
+ *lock = false;
+
+ result
}
diff --git a/fincept-terminal-desktop/src-tauri/src/utils/python.rs b/fincept-terminal-desktop/src-tauri/src/utils/python.rs
index 6035d5449..f5c5c3944 100644
--- a/fincept-terminal-desktop/src-tauri/src/utils/python.rs
+++ b/fincept-terminal-desktop/src-tauri/src/utils/python.rs
@@ -2,10 +2,40 @@
use std::path::PathBuf;
use tauri::Manager;
+/// NumPy 1.x compatible libraries (use venv-numpy1)
+const NUMPY1_LIBRARIES: &[&str] = &[
+ "vectorbt",
+ "backtesting",
+ "gluonts",
+ "functime",
+ "PyPortfolioOpt",
+ "pyqlib",
+ "rdagent",
+ "gs-quant",
+];
+
+/// Determine which venv to use based on library name
+fn get_venv_for_library(library_name: Option<&str>) -> &'static str {
+ if let Some(lib) = library_name {
+ // Check if library requires NumPy 1.x
+ if NUMPY1_LIBRARIES.iter().any(|&numpy1_lib| lib.contains(numpy1_lib)) {
+ return "venv-numpy1";
+ }
+ }
+ // Default to NumPy 2.x venv
+ "venv-numpy2"
+}
+
/// Get the Python executable path from app installation directory
+/// Supports dual-venv setup for NumPy 1.x and 2.x compatibility
/// In production: Uses installed Python from setup.rs
/// In development: Uses %LOCALAPPDATA%/fincept-dev (matches setup.rs)
pub fn get_python_path(app: &tauri::AppHandle) -> Result<PathBuf, String> {
+ get_python_path_for_library(app, None)
+}
+
+/// Get Python path for a specific library (switches between numpy1 and numpy2 venvs)
+pub fn get_python_path_for_library(app: &tauri::AppHandle, library_name: Option<&str>) -> Result<PathBuf, String> {
// Get install directory (same logic as setup.rs)
let install_dir = if cfg!(debug_assertions) {
// Dev mode: use OS-specific user directory
@@ -30,28 +60,33 @@ pub fn get_python_path(app: &tauri::AppHandle) -> Result<PathBuf, String> {
.map_err(|e| format!("Failed to get resource directory: {}", e))?
};
- // Platform-specific Python executable location
+ // Determine which venv to use based on library
+ let venv_name = get_venv_for_library(library_name);
+
+ // Platform-specific Python executable location in venv
let python_exe = if cfg!(target_os = "windows") {
- install_dir.join("python").join("python.exe")
+ install_dir.join(format!("{}/Scripts/python.exe", venv_name))
} else {
- install_dir.join("python").join("bin").join("python3")
+ install_dir.join(format!("{}/bin/python3", venv_name))
};
- // DEVELOPMENT MODE: Use bundled Python (where packages are installed)
+ eprintln!("[PYTHON] Library: {:?}, Using venv: {}, Path: {}", library_name, venv_name, python_exe.display());
+
+ // Check if venv Python exists
+ if python_exe.exists() {
+ // Strip the \\?\ prefix that can cause issues on Windows
+ let path_str = python_exe.to_string_lossy().to_string();
+ let clean_path = if path_str.starts_with(r"\\?\") {
+ PathBuf::from(&path_str[4..])
+ } else {
+ python_exe.clone()
+ };
+ return Ok(clean_path);
+ }
+
+ // Fallback to system Python in dev mode only
#[cfg(debug_assertions)]
{
- // Check bundled Python first (has all packages installed)
- if python_exe.exists() {
- let path_str = python_exe.to_string_lossy().to_string();
- let clean_path = if path_str.starts_with(r"\\?\") {
- PathBuf::from(&path_str[4..])
- } else {
- python_exe.clone()
- };
- return Ok(clean_path);
- }
-
- // Fallback to system Python if bundled not found
use std::process::Command;
let system_python = if cfg!(target_os = "windows") {
"python"
@@ -61,33 +96,21 @@ pub fn get_python_path(app: &tauri::AppHandle) -> Result<PathBuf, String> {
if let Ok(output) = Command::new(system_python).arg("--version").output() {
if output.status.success() {
+ eprintln!("[PYTHON] Warning: Using system Python as fallback");
return Ok(PathBuf::from(system_python));
}
}
}
- // PRODUCTION MODE: Check bundled Python
- #[cfg(not(debug_assertions))]
- if python_exe.exists() {
- // Strip the \\?\ prefix that can cause issues on Windows
- let path_str = python_exe.to_string_lossy().to_string();
- let clean_path = if path_str.starts_with(r"\\?\") {
- PathBuf::from(&path_str[4..])
- } else {
- python_exe
- };
- return Ok(clean_path);
- }
-
// If we get here, Python is not available
Err(format!(
"Python interpreter not found at: {}\n\n\
The Python runtime is required to run analytics and data processing features.\n\n\
Troubleshooting steps:\n\
1. Run the setup wizard from the application to install Python\n\
- 2. If setup fails, ensure Microsoft Visual C++ Redistributable is installed:\n\
+ 2. Ensure both venv-numpy1 and venv-numpy2 are created\n\
+ 3. If setup fails, ensure Microsoft Visual C++ Redistributable is installed:\n\
Download from: https://aka.ms/vs/17/release/vc_redist.x64.exe\n\
- 3. Alternatively, install Python 3.12 manually from: https://www.python.org/downloads/\n\
4. Restart the application after installation",
python_exe.display()
))
diff --git a/fincept-terminal-desktop/src-tauri/src/websocket/adapters/binance.rs b/fincept-terminal-desktop/src-tauri/src/websocket/adapters/binance.rs
index 49091e5e0..4788c919b 100644
--- a/fincept-terminal-desktop/src-tauri/src/websocket/adapters/binance.rs
+++ b/fincept-terminal-desktop/src-tauri/src/websocket/adapters/binance.rs
@@ -63,7 +63,7 @@ impl BinanceAdapter {
let high = data.get("h")?.as_str()?.parse::<f64>().ok();
let low = data.get("l")?.as_str()?.parse::<f64>().ok();
let volume = data.get("v")?.as_str()?.parse::<f64>().ok();
- let quote_volume = data.get("q")?.as_str()?.parse::<f64>().ok();
+ let _quote_volume = data.get("q")?.as_str()?.parse::<f64>().ok();
// Calculate change percent
let change_percent = if let Some(open_price) = open {
diff --git a/fincept-terminal-desktop/src/components/setup/SetupScreen.tsx b/fincept-terminal-desktop/src/components/setup/SetupScreen.tsx
index 05d6c1ef0..e8f756a28 100644
--- a/fincept-terminal-desktop/src/components/setup/SetupScreen.tsx
+++ b/fincept-terminal-desktop/src/components/setup/SetupScreen.tsx
@@ -1,7 +1,8 @@
-// SetupScreen.tsx - First-time setup screen with progress tracking
+// SetupScreen.tsx - Bloomberg-style setup screen for embedded Python
import React, { useState, useEffect } from 'react';
import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';
+import { Loader2, CheckCircle, AlertCircle, ChevronDown, ChevronUp } from 'lucide-react';
interface SetupProgress {
step: string;
@@ -13,8 +14,7 @@ interface SetupProgress {
interface SetupStatus {
python_installed: boolean;
bun_installed: boolean;
- python_version: string | null;
- bun_version: string | null;
+ packages_installed: boolean;
needs_setup: boolean;
}
@@ -22,6 +22,24 @@ interface SetupScreenProps {
onSetupComplete: () => void;
}
+// Bloomberg Professional Color Palette
+const BLOOMBERG = {
+ ORANGE: '#FF8800',
+ WHITE: '#FFFFFF',
+ RED: '#FF3B3B',
+ GREEN: '#00D66F',
+ GRAY: '#787878',
+ DARK_BG: '#000000',
+ PANEL_BG: '#0F0F0F',
+ HEADER_BG: '#1A1A1A',
+ CYAN: '#00E5FF',
+ YELLOW: '#FFD700',
+ BLUE: '#0088FF',
+ BORDER: '#2A2A2A',
+ HOVER: '#1F1F1F',
+ MUTED: '#4A4A4A'
+};
+
const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
const [isChecking, setIsChecking] = useState(true);
const [isInstalling, setIsInstalling] = useState(false);
@@ -47,12 +65,10 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
setSetupStatus(status);
if (!status.needs_setup) {
- // Already set up, proceed to app
setTimeout(() => onSetupComplete(), 1000);
} else {
- // Need to run setup
setIsChecking(false);
- runSetup();
+ // Don't auto-run setup, let user trigger it
}
} catch (err) {
console.error('Failed to check setup status:', err);
@@ -67,7 +83,6 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
setCurrentStep(progress.step);
setCurrentMessage(progress.message);
- // Add to logs for transparency
if (progress.message) {
setInstallationLogs(prev => [...prev, `[${progress.step}] ${progress.message}`]);
}
@@ -77,7 +92,6 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
return;
}
- // Update progress for each step
switch (progress.step) {
case 'python':
setPythonProgress(progress.progress);
@@ -94,7 +108,6 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
}
});
- // Cleanup listener on unmount
return () => {
unlisten();
};
@@ -113,7 +126,6 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
};
const retrySetup = () => {
- console.log('[SetupScreen] Retry button clicked');
setError(null);
setPythonProgress(0);
setBunProgress(0);
@@ -128,15 +140,18 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
if (isChecking) {
return (
- <div className="min-h-screen bg-black flex items-center justify-center">
+ <div className="min-h-screen flex items-center justify-center" style={{ backgroundColor: BLOOMBERG.DARK_BG }}>
<div className="text-center space-y-6">
- <div className="relative">
- <div className="w-20 h-20 border-4 border-zinc-800 rounded-full mx-auto"></div>
- <div className="w-20 h-20 border-4 border-t-emerald-500 rounded-full animate-spin absolute top-0 left-1/2 transform -translate-x-1/2"></div>
+ <div className="relative inline-block">
+ <Loader2 className="w-16 h-16 animate-spin" style={{ color: BLOOMBERG.ORANGE }} />
</div>
<div>
- <h2 className="text-2xl font-bold text-white mb-2">Fincept Terminal</h2>
- <p className="text-zinc-400">Checking system requirements...</p>
+ <h2 className="text-2xl font-bold tracking-wide" style={{ color: BLOOMBERG.WHITE }}>
+ FINCEPT TERMINAL
+ </h2>
+ <p className="text-sm font-mono mt-2" style={{ color: BLOOMBERG.GRAY }}>
+ CHECKING SYSTEM REQUIREMENTS...
+ </p>
</div>
</div>
</div>
@@ -144,121 +159,175 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
}
return (
- <div className="min-h-screen bg-black flex items-center justify-center p-8">
- <div className="max-w-2xl w-full space-y-8">
+ <div className="min-h-screen flex items-center justify-center p-8" style={{ backgroundColor: BLOOMBERG.DARK_BG }}>
+ <div className="max-w-4xl w-full space-y-6">
{/* Header */}
- <div className="text-center space-y-4">
- <h1 className="text-4xl font-bold text-white">Welcome to Fincept Terminal</h1>
- <p className="text-zinc-400 text-lg">
- Setting up your environment for the first time...
+ <div className="text-center space-y-3 pb-6 border-b" style={{ borderColor: BLOOMBERG.BORDER }}>
+ <div className="inline-block px-4 py-2 rounded" style={{ backgroundColor: BLOOMBERG.ORANGE }}>
+ <h1 className="text-2xl font-bold tracking-wider" style={{ color: BLOOMBERG.DARK_BG }}>
+ FINCEPT TERMINAL
+ </h1>
+ </div>
+ <p className="text-sm font-mono tracking-wide" style={{ color: BLOOMBERG.GRAY }}>
+ FIRST-TIME SETUP | INSTALLING EMBEDDED RUNTIME
</p>
{setupStatus && !setupStatus.needs_setup && (
- <p className="text-emerald-500 text-sm">[OK] System is ready!</p>
+ <p className="text-xs font-mono" style={{ color: BLOOMBERG.GREEN }}>
+ [OK] SYSTEM READY
+ </p>
)}
</div>
+ {/* Begin Setup Button */}
+ {!isInstalling && setupStatus?.needs_setup && (
+ <div className="text-center">
+ <button
+ onClick={runSetup}
+ className="px-8 py-4 rounded font-bold text-sm tracking-wider transition-all"
+ style={{
+ backgroundColor: BLOOMBERG.ORANGE,
+ color: BLOOMBERG.DARK_BG
+ }}
+ onMouseEnter={(e) => e.currentTarget.style.transform = 'scale(1.05)'}
+ onMouseLeave={(e) => e.currentTarget.style.transform = 'scale(1)'}
+ >
+ BEGIN SETUP
+ </button>
+ </div>
+ )}
+
{/* Setup Progress */}
- {(isInstalling || setupStatus?.needs_setup) && (
- <div className="bg-zinc-900 rounded-lg border border-zinc-800 p-8 space-y-6">
+ {isInstalling && (
+ <div className="rounded border" style={{ backgroundColor: BLOOMBERG.PANEL_BG, borderColor: BLOOMBERG.BORDER }}>
{/* Python Installation */}
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center space-x-3">
- <div className={`w-8 h-8 rounded-full flex items-center justify-center transition-all duration-300 ${
- pythonProgress === 100 ? 'bg-emerald-500 scale-110' :
- pythonProgress > 0 ? 'bg-blue-500 animate-pulse' : 'bg-zinc-800'
- }`}>
- {pythonProgress === 100 ? '[OK]' : '1'}
- </div>
- <div className="flex-1">
- <h3 className="text-white font-semibold">Python 3.12.7</h3>
- <p className="text-zinc-500 text-sm">
- {setupStatus?.python_installed
- ? `Installed: ${setupStatus.python_version}`
- : 'Required for analytics and data processing'}
+ <div className="p-6 border-b" style={{ borderColor: BLOOMBERG.BORDER }}>
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center space-x-4">
+ {pythonProgress === 100 ? (
+ <CheckCircle className="w-6 h-6" style={{ color: BLOOMBERG.GREEN }} />
+ ) : pythonProgress > 0 ? (
+ <Loader2 className="w-6 h-6 animate-spin" style={{ color: BLOOMBERG.ORANGE }} />
+ ) : (
+ <div className="w-6 h-6 rounded-full border-2 flex items-center justify-center" style={{ borderColor: BLOOMBERG.MUTED }}>
+ <span className="text-xs font-bold" style={{ color: BLOOMBERG.MUTED }}>1</span>
+ </div>
+ )}
+ <div>
+ <h3 className="text-sm font-bold tracking-wide" style={{ color: BLOOMBERG.WHITE }}>
+ PYTHON 3.12.7 EMBEDDED RUNTIME
+ </h3>
+ <p className="text-xs font-mono mt-1" style={{ color: BLOOMBERG.GRAY }}>
+ {setupStatus?.python_installed ? 'INSTALLED' : 'DOWNLOADING & EXTRACTING'}
</p>
</div>
</div>
- <span className="text-zinc-400 text-sm font-mono">{pythonProgress}%</span>
+ <span className="text-xs font-mono tabular-nums" style={{ color: BLOOMBERG.ORANGE }}>
+ {pythonProgress}%
+ </span>
</div>
- <div className="w-full bg-zinc-800 rounded-full h-2 overflow-hidden">
+ <div className="w-full h-1 rounded-full overflow-hidden" style={{ backgroundColor: BLOOMBERG.BORDER }}>
<div
- className="bg-gradient-to-r from-blue-500 to-emerald-500 h-full transition-all duration-500 ease-out"
- style={{ width: `${pythonProgress}%` }}
+ className="h-full transition-all duration-500"
+ style={{
+ width: `${pythonProgress}%`,
+ backgroundColor: pythonProgress === 100 ? BLOOMBERG.GREEN : BLOOMBERG.ORANGE
+ }}
/>
</div>
{currentStep === 'python' && currentMessage && (
- <div className="flex items-center space-x-2 text-sm">
- <div className="w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"></div>
- <p className="text-blue-300 font-medium animate-fade-in">{currentMessage}</p>
+ <div className="flex items-center space-x-2 mt-2">
+ <div className="w-1 h-1 rounded-full animate-pulse" style={{ backgroundColor: BLOOMBERG.ORANGE }} />
+ <p className="text-xs font-mono" style={{ color: BLOOMBERG.CYAN }}>
+ {currentMessage}
+ </p>
</div>
)}
</div>
{/* Bun Installation */}
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center space-x-3">
- <div className={`w-8 h-8 rounded-full flex items-center justify-center transition-all duration-300 ${
- bunProgress === 100 ? 'bg-emerald-500 scale-110' :
- bunProgress > 0 ? 'bg-blue-500 animate-pulse' : 'bg-zinc-800'
- }`}>
- {bunProgress === 100 ? '[OK]' : '2'}
- </div>
- <div className="flex-1">
- <h3 className="text-white font-semibold">Bun v1.1.0</h3>
- <p className="text-zinc-500 text-sm">
- {setupStatus?.bun_installed
- ? `Installed: ${setupStatus.bun_version}`
- : 'Required for MCP servers (bunx)'}
+ <div className="p-6 border-b" style={{ borderColor: BLOOMBERG.BORDER }}>
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center space-x-4">
+ {bunProgress === 100 ? (
+ <CheckCircle className="w-6 h-6" style={{ color: BLOOMBERG.GREEN }} />
+ ) : bunProgress > 0 ? (
+ <Loader2 className="w-6 h-6 animate-spin" style={{ color: BLOOMBERG.ORANGE }} />
+ ) : (
+ <div className="w-6 h-6 rounded-full border-2 flex items-center justify-center" style={{ borderColor: BLOOMBERG.MUTED }}>
+ <span className="text-xs font-bold" style={{ color: BLOOMBERG.MUTED }}>2</span>
+ </div>
+ )}
+ <div>
+ <h3 className="text-sm font-bold tracking-wide" style={{ color: BLOOMBERG.WHITE }}>
+ BUN v1.1.0 RUNTIME
+ </h3>
+ <p className="text-xs font-mono mt-1" style={{ color: BLOOMBERG.GRAY }}>
+ {setupStatus?.bun_installed ? 'INSTALLED' : 'JAVASCRIPT RUNTIME FOR MCP SERVERS'}
</p>
</div>
</div>
- <span className="text-zinc-400 text-sm font-mono">{bunProgress}%</span>
+ <span className="text-xs font-mono tabular-nums" style={{ color: BLOOMBERG.ORANGE }}>
+ {bunProgress}%
+ </span>
</div>
- <div className="w-full bg-zinc-800 rounded-full h-2 overflow-hidden">
+ <div className="w-full h-1 rounded-full overflow-hidden" style={{ backgroundColor: BLOOMBERG.BORDER }}>
<div
- className="bg-gradient-to-r from-blue-500 to-emerald-500 h-full transition-all duration-500 ease-out"
- style={{ width: `${bunProgress}%` }}
+ className="h-full transition-all duration-500"
+ style={{
+ width: `${bunProgress}%`,
+ backgroundColor: bunProgress === 100 ? BLOOMBERG.GREEN : BLOOMBERG.ORANGE
+ }}
/>
</div>
{currentStep === 'bun' && currentMessage && (
- <div className="flex items-center space-x-2 text-sm">
- <div className="w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"></div>
- <p className="text-blue-300 font-medium animate-fade-in">{currentMessage}</p>
+ <div className="flex items-center space-x-2 mt-2">
+ <div className="w-1 h-1 rounded-full animate-pulse" style={{ backgroundColor: BLOOMBERG.ORANGE }} />
+ <p className="text-xs font-mono" style={{ color: BLOOMBERG.CYAN }}>
+ {currentMessage}
+ </p>
</div>
)}
</div>
- {/* Python Packages Installation */}
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center space-x-3">
- <div className={`w-8 h-8 rounded-full flex items-center justify-center transition-all duration-300 ${
- packagesProgress === 100 ? 'bg-emerald-500 scale-110' :
- packagesProgress > 0 ? 'bg-blue-500 animate-pulse' : 'bg-zinc-800'
- }`}>
- {packagesProgress === 100 ? '[OK]' : '3'}
- </div>
- <div className="flex-1">
- <h3 className="text-white font-semibold">Python Libraries</h3>
- <p className="text-zinc-500 text-sm">
- Installing pandas, numpy, yfinance, and more...
+ {/* Python Packages */}
+ <div className="p-6">
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center space-x-4">
+ {packagesProgress === 100 ? (
+ <CheckCircle className="w-6 h-6" style={{ color: BLOOMBERG.GREEN }} />
+ ) : packagesProgress > 0 ? (
+ <Loader2 className="w-6 h-6 animate-spin" style={{ color: BLOOMBERG.ORANGE }} />
+ ) : (
+ <div className="w-6 h-6 rounded-full border-2 flex items-center justify-center" style={{ borderColor: BLOOMBERG.MUTED }}>
+ <span className="text-xs font-bold" style={{ color: BLOOMBERG.MUTED }}>3</span>
+ </div>
+ )}
+ <div>
+ <h3 className="text-sm font-bold tracking-wide" style={{ color: BLOOMBERG.WHITE }}>
+ PYTHON LIBRARIES | NUMPY 2.x
+ </h3>
+ <p className="text-xs font-mono mt-1" style={{ color: BLOOMBERG.GRAY }}>
+ NUMPY, PANDAS, TORCH, VNPY, LANGCHAIN, +80 PACKAGES
</p>
</div>
</div>
- <span className="text-zinc-400 text-sm font-mono">{packagesProgress}%</span>
+ <span className="text-xs font-mono tabular-nums" style={{ color: BLOOMBERG.ORANGE }}>
+ {packagesProgress}%
+ </span>
</div>
- <div className="w-full bg-zinc-800 rounded-full h-2 overflow-hidden">
+ <div className="w-full h-1 rounded-full overflow-hidden" style={{ backgroundColor: BLOOMBERG.BORDER }}>
<div
- className="bg-gradient-to-r from-blue-500 to-emerald-500 h-full transition-all duration-500 ease-out"
- style={{ width: `${packagesProgress}%` }}
+ className="h-full transition-all duration-500"
+ style={{
+ width: `${packagesProgress}%`,
+ backgroundColor: packagesProgress === 100 ? BLOOMBERG.GREEN : BLOOMBERG.ORANGE
+ }}
/>
</div>
{currentStep === 'packages' && currentMessage && (
- <div className="flex items-center space-x-2 text-sm">
- <div className="w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"></div>
- <p className="text-blue-300 font-medium animate-fade-in">
+ <div className="flex items-center space-x-2 mt-2">
+ <div className="w-1 h-1 rounded-full animate-pulse" style={{ backgroundColor: BLOOMBERG.ORANGE }} />
+ <p className="text-xs font-mono" style={{ color: BLOOMBERG.CYAN }}>
{currentMessage}
</p>
</div>
@@ -269,85 +338,97 @@ const SetupScreen: React.FC<SetupScreenProps> = ({ onSetupComplete }) => {
{/* Error Display */}
{error && (
- <div className="bg-red-900/20 border border-red-500/50 rounded-lg p-4 space-y-3">
- <div className="flex items-start space-x-3">
- <span className="text-red-500 text-xl">[WARN]</span>
+ <div className="rounded border p-6" style={{ backgroundColor: BLOOMBERG.PANEL_BG, borderColor: BLOOMBERG.RED }}>
+ <div className="flex items-start space-x-4 mb-4">
+ <AlertCircle className="w-6 h-6 flex-shrink-0" style={{ color: BLOOMBERG.RED }} />
<div className="flex-1">
- <h4 className="text-red-500 font-semibold">Setup Error</h4>
- <p className="text-red-300 text-sm mt-1">{error}</p>
+ <h4 className="text-sm font-bold tracking-wide mb-2" style={{ color: BLOOMBERG.RED }}>
+ SETUP ERROR
+ </h4>
+ <p className="text-xs font-mono" style={{ color: BLOOMBERG.WHITE }}>
+ {error}
+ </p>
</div>
</div>
<button
onClick={retrySetup}
- className="w-full bg-red-600 hover:bg-red-700 text-white py-2 rounded-lg transition-colors"
+ className="w-full py-3 rounded font-bold text-xs tracking-wider transition-colors"
+ style={{
+ backgroundColor: BLOOMBERG.RED,
+ color: BLOOMBERG.WHITE
+ }}
+ onMouseEnter={(e) => e.currentTarget.style.opacity = '0.9'}
+ onMouseLeave={(e) => e.currentTarget.style.opacity = '1'}
>
- Retry Setup
+ RETRY SETUP
</button>
</div>
)}
{/* Info Box */}
{!error && (
- <div className="bg-blue-900/20 border border-blue-500/50 rounded-lg p-4 space-y-3">
- <div className="flex items-start space-x-3">
- <svg
- className="w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
- <div className="flex-1 space-y-2">
- <p className="text-blue-300 text-sm">
- <strong>Note:</strong> This is a one-time setup process. The application will download and install the necessary runtimes for optimal performance.
+ <div className="rounded border p-6" style={{ backgroundColor: BLOOMBERG.PANEL_BG, borderColor: BLOOMBERG.BORDER }}>
+ <div className="space-y-3 text-xs font-mono">
+ <div className="flex items-start space-x-2">
+ <span style={{ color: BLOOMBERG.ORANGE }}>[INFO]</span>
+ <p style={{ color: BLOOMBERG.WHITE }}>
+ ONE-TIME SETUP: INSTALLING EMBEDDED PYTHON + NUMPY 2.x COMPATIBLE LIBRARIES
</p>
- <p className="text-blue-200 text-sm font-medium">
- This process may take a few minutes to complete. On older CPUs, it might take longer.
+ </div>
+ <div className="flex items-start space-x-2">
+ <span style={{ color: BLOOMBERG.CYAN }}>[TIME]</span>
+ <p style={{ color: BLOOMBERG.GRAY }}>
+ ESTIMATED: 5-15 MINUTES DEPENDING ON NETWORK SPEED AND CPU
</p>
- <p className="text-yellow-300 text-sm font-semibold">
- [WARN]️ Please do not close the application during installation. Wait for the process to complete.
+ </div>
+ <div className="flex items-start space-x-2">
+ <span style={{ color: BLOOMBERG.YELLOW }}>[WARN]</span>
+ <p style={{ color: BLOOMBERG.YELLOW }}>
+ DO NOT CLOSE APPLICATION DURING INSTALLATION
</p>
</div>
</div>
</div>
)}
- {/* Installation Logs (Collapsible) */}
+ {/* Installation Logs */}
{isInstalling && installationLogs.length > 0 && (
- <div className="bg-zinc-900 border border-zinc-800 rounded-lg overflow-hidden">
+ <div className="rounded border overflow-hidden" style={{ backgroundColor: BLOOMBERG.PANEL_BG, borderColor: BLOOMBERG.BORDER }}>
<button
onClick={() => setShowLogs(!showLogs)}
- className="w-full px-4 py-3 flex items-center justify-between text-left hover:bg-zinc-800 transition-colors"
+ className="w-full px-6 py-4 flex items-center justify-between transition-colors"
+ style={{ backgroundColor: BLOOMBERG.HEADER_BG }}
+ onMouseEnter={(e) => e.currentTarget.style.backgroundColor = BLOOMBERG.HOVER}
+ onMouseLeave={(e) => e.currentTarget.style.backgroundColor = BLOOMBERG.HEADER_BG}
>
- <div className="flex items-center space-x-2">
- <svg
- className={`w-4 h-4 text-zinc-400 transition-transform ${showLogs ? 'rotate-90' : ''}`}
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- >
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
- </svg>
- <span className="text-white font-medium">Installation Logs</span>
- <span className="text-zinc-500 text-sm">({installationLogs.length} entries)</span>
+ <div className="flex items-center space-x-3">
+ {showLogs ? (
+ <ChevronUp className="w-4 h-4" style={{ color: BLOOMBERG.ORANGE }} />
+ ) : (
+ <ChevronDown className="w-4 h-4" style={{ color: BLOOMBERG.ORANGE }} />
+ )}
+ <span className="text-xs font-bold tracking-wide" style={{ color: BLOOMBERG.WHITE }}>
+ INSTALLATION LOGS
+ </span>
+ <span className="text-xs font-mono" style={{ color: BLOOMBERG.GRAY }}>
+ ({installationLogs.length})
+ </span>
</div>
- <span className="text-zinc-500 text-xs">Click to {showLogs ? 'hide' : 'show'}</span>
+ <span className="text-xs font-mono" style={{ color: BLOOMBERG.GRAY }}>
+ {showLogs ? 'HIDE' : 'SHOW'}
+ </span>
</button>
{showLogs && (
- <div className="border-t border-zinc-800 bg-black/40 p-4 max-h-64 overflow-y-auto font-mono text-xs">
- {installationLogs.map((log, index) => (
+ <div className="border-t p-4 max-h-64 overflow-y-auto font-mono text-xs" style={{ borderColor: BLOOMBERG.BORDER, backgroundColor: BLOOMBERG.DARK_BG }}>
+ {installationLogs.map((log, idx) => (
<div
- key={index}
- className="text-zinc-400 py-0.5 hover:bg-zinc-800/50 px-2 rounded animate-fade-in"
+ key={idx}
+ className="py-1 px-2 rounded hover:bg-opacity-50 transition-colors"
+ style={{ color: BLOOMBERG.GRAY }}
+ onMouseEnter={(e) => e.currentTarget.style.backgroundColor = BLOOMBERG.HOVER}
+ onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'transparent'}
>
- <span className="text-zinc-600 mr-2">{index + 1}.</span>
- {log}
+ <span style={{ color: BLOOMBERG.MUTED }}>[{idx + 1}]</span> {log}
</div>
))}
</div>