-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_uv.ps1
More file actions
49 lines (40 loc) · 1.29 KB
/
run_uv.ps1
File metadata and controls
49 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#Requires -Version 7
$ErrorActionPreference = "Stop"
# --- CONFIG ---
$VENV_DIR = ".venv"
$SCRIPT_NAME = "main.py"
$WINDOW_TITLE = "UV-App-Starter-Pack"
# Handle dry-run mode
if (-not $env:UV_APP_DRY) { $env:UV_APP_DRY = "0" }
Write-Host "Dry Run Mode: $env:UV_APP_DRY"
# --- Core Setup ---
# Check Python
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
throw "Python not found in PATH!"
}
# Check UV
if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
throw "UV not installed. Install with: pip install uv"
}
# Create venv
if (-not (Test-Path $VENV_DIR)) {
Write-Host "Creating venv..."
uv venv $VENV_DIR --python python3.11
if (-not $?) { throw "Venv creation failed!" }
}
# Activate
& "$VENV_DIR\Scripts\Activate.ps1"
# Install core requirements
Write-Host "Installing core dependencies..."
uv pip install -r requirements.txt
if (-not $?) { throw "Dependency installation failed!" }
# Conditional PyTorch install
if ($env:UV_APP_DRY -eq "0") {
Write-Host "Installing PyTorch..."
python install_pytorch.py
if (-not $?) { Write-Warning "PyTorch install failed. App may lack GPU support." }
} else {
Write-Host "[Dry Run] Skipped PyTorch installation"
}
# Launch app
Start-Process python -ArgumentList "$SCRIPT_NAME" -WindowStyle Normal -Title $WINDOW_TITLE