-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
67 lines (60 loc) · 1.88 KB
/
Copy pathrun.ps1
File metadata and controls
67 lines (60 loc) · 1.88 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
# run.ps1 - Create venv, install deps, copy .env.example -> .env, run app
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Ensure python is available
try {
python --version | Out-Null
} catch {
Write-Error "Python is not on PATH. Install Python 3.9+ and re-run."
exit 1
}
$projectRoot = $PSScriptRoot
$venvPath = Join-Path $projectRoot ".venv"
# Create virtual environment if missing
if (-not (Test-Path $venvPath)) {
Write-Host "Creating virtual environment at $venvPath..."
python -m venv $venvPath
}
# Activate venv for this script
$activate = Join-Path $venvPath "Scripts\Activate.ps1"
if (Test-Path $activate) {
Write-Host "Activating virtual environment..."
. $activate
} else {
Write-Error "Activation script not found at $activate"
exit 1
}
# Upgrade pip and install requirements
Write-Host "Upgrading pip and installing dependencies..."
python -m pip install --upgrade pip
$req = Join-Path $projectRoot "requirements.txt"
if (Test-Path $req) {
pip install -r $req
} else {
Write-Warning "requirements.txt not found in project root."
}
# Create .env from example if missing
$envFile = Join-Path $projectRoot ".env"
$envExample = Join-Path $projectRoot ".env.example"
if (-not (Test-Path $envFile)) {
if (Test-Path $envExample) {
Copy-Item -Path $envExample -Destination $envFile
Write-Host "Created .env from .env.example. Please edit .env to add secrets."
} else {
Write-Host "Creating .env with placeholder values..."
@"
SESSION_SECRET=change-me
GEMINI_API_KEY=
MAIL_SERVER=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
"@ | Out-File -Encoding utf8 $envFile
Write-Host "Created .env — edit it with real values before using production features."
}
} else {
Write-Host ".env already exists. Skipping creation."
}
# Run the app
Write-Host "Starting LearnNest app (python app.py)..."
python app.py