forked from morphik-org/morphik-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_and_start.ps1
More file actions
142 lines (124 loc) · 5.36 KB
/
Copy pathinstall_and_start.ps1
File metadata and controls
142 lines (124 loc) · 5.36 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<#
Morphik Core one-liner installer + server launcher for Windows PowerShell.
Mirrors install_and_start.sh (macOS/Linux) but uses Windows-friendly commands.
Usage (PowerShell):
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
./install_and_start.ps1
Requirements:
- Docker Desktop running (used for local Redis container and optional services)
- Python 3.10+ (3.12 recommended)
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
function Write-Info($msg) { Write-Host "`n[INFO] $msg" -ForegroundColor Cyan }
function Write-Step($msg) { Write-Host "`n[STEP] $msg" -ForegroundColor Yellow }
function Write-Ok($msg) { Write-Host "`n[OK] $msg" -ForegroundColor Green }
function Write-Err($msg) { Write-Host "`n[ERR] $msg" -ForegroundColor Red }
function Assert-Docker {
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
Write-Err "Docker is required (used to run a local Redis container). Install Docker Desktop first."
throw "Docker not found"
}
cmd.exe /c "docker info >NUL 2>&1"
if ($LASTEXITCODE -ne 0) {
Write-Err "Docker is installed but not running. Please start Docker Desktop and re-run."
throw "Docker not running"
}
}
function Ensure-Uv {
$uvCmd = Get-Command uv -ErrorAction SilentlyContinue
if (-not $uvCmd) {
Write-Step "Installing uv (Python packaging tool)..."
if (Get-Command py -ErrorAction SilentlyContinue) {
py -m pip install --user --upgrade uv
} elseif (Get-Command python -ErrorAction SilentlyContinue) {
python -m pip install --user --upgrade uv
} else {
Write-Err "Python not found. Please install Python 3.12 (recommended) from python.org, then re-run."
throw "Python not found"
}
# Try to locate uv.exe in the user's Scripts directory if PATH wasn't updated
$uvCmd = Get-Command uv -ErrorAction SilentlyContinue
if (-not $uvCmd) {
try {
if (Get-Command py -ErrorAction SilentlyContinue) {
$userBase = & py -c "import site; print(site.USER_BASE)" 2>$null
$pyver = & py -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')" 2>$null
} elseif (Get-Command python -ErrorAction SilentlyContinue) {
$userBase = & python -c "import site; print(site.USER_BASE)" 2>$null
$pyver = & python -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')" 2>$null
} else { $userBase = $null }
} catch { $userBase = $null }
$candidates = @()
if ($userBase) { $candidates += (Join-Path $userBase 'Scripts/uv.exe') }
if ($pyver) {
if ($env:APPDATA) { $candidates += (Join-Path $env:APPDATA ("Python/Python$pyver/Scripts/uv.exe")) }
if ($env:LOCALAPPDATA) { $candidates += (Join-Path $env:LOCALAPPDATA ("Programs/Python/Python$pyver/Scripts/uv.exe")) }
}
foreach ($cand in $candidates) {
if ($cand -and (Test-Path $cand)) {
$dir = [System.IO.Path]::GetDirectoryName($cand)
if ($dir -and ($env:Path -notlike "*$dir*")) { $env:Path = "$dir;$env:Path" }
$uvCmd = Get-Command uv -ErrorAction SilentlyContinue
if ($uvCmd) { break }
}
}
}
if (-not $uvCmd) {
Write-Err "uv was installed but not found on PATH. Open a new PowerShell window or add your Python Scripts folder to PATH, then retry."
throw "uv not on PATH"
}
}
}
function Ensure-EnvFile {
if (-not (Test-Path .env) -and (Test-Path .env.example)) {
Write-Step "Creating default .env from .env.example..."
Copy-Item .env.example .env
}
}
function Ensure-Py312 {
$exe = $null
if (Get-Command py -ErrorAction SilentlyContinue) {
try { $exe = & py -3.12 -c "import sys; print(sys.executable)" 2>$null } catch { $exe = $null }
}
if (-not $exe -or -not (Test-Path $exe)) {
if (Get-Command python -ErrorAction SilentlyContinue) {
try {
$ver = & python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null
if ($ver -eq '3.12') { $exe = (Get-Command python).Source }
} catch { $exe = $null }
}
}
if (-not $exe -or -not (Test-Path $exe)) {
Write-Err "Python 3.12 not found. Please install Python 3.12 from python.org (or via the Microsoft Store), then re-run."
throw "Python 3.12 not found"
}
Write-Info "Using Python 3.12 at: $exe"
return $exe
}
$arch = $env:PROCESSOR_ARCHITECTURE
if (-not $arch) { $arch = "unknown" }
Write-Info "Detected OS: Windows | Arch: $arch"
# 1) Check Docker
Assert-Docker
# 2) Ensure uv is available
Ensure-Uv
# 3) Create/Sync virtual environment and install project deps
Write-Step "Installing project dependencies with uv..."
$py312 = Ensure-Py312
uv sync --python $py312
# 4) Ensure .env exists
Ensure-EnvFile
# 4b) Ensure we install into the project's venv (not a global Conda/Python)
$venvPython = Join-Path (Get-Location) '.venv\Scripts\python.exe'
if (-not (Test-Path $venvPython)) {
Write-Err "Project virtual environment was not created at .venv. Please re-run 'uv sync'."
throw ".venv not found"
}
# 5) Install ColPali engine (multimodal search)
Write-Step "Installing ColPali engine..."
uv pip install --python $venvPython `
colpali-engine@git+https://github.com/illuin-tech/colpali@80fb72c9b827ecdb5687a3a8197077d0d01791b3
# 6) Start the server
Write-Host "`nStarting Morphik server...`n" -ForegroundColor Green
uv run --python $venvPython start_server.py