-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-win.ps1
58 lines (49 loc) · 1.56 KB
/
setup-win.ps1
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
# Update system packages (not applicable for Windows)
# Find Python version (assuming Python is installed and accessible in the PATH)
$pythonVersion = &python -V 2>&1
if ($pythonVersion -notmatch "Python 3\.\d+") {
Write-Output "Error: No suitable Python version found."
return
}
# Check if the Python version is above 3.10
if ($pythonVersion -match "Python 3\.(\d+)") {
$minorVersion = [int]$matches[1]
if ($minorVersion -lt 10) {
Write-Output "Error: Python version must be 3.10 or higher. Found: $pythonVersion"
return
}
}
else {
Write-Output "Error: Failed to determine Python version."
return
}
# Check if virtual environment already exists
if (-not (Test-Path ".venv")) {
Write-Output "Creating virtual environment..."
python -m venv .venv
Write-Output "Virtual environment created."
}
else {
Write-Output "Virtual environment already exists."
}
# Activate virtual environment
& .\.venv\Scripts\Activate
# Upgrade pip using Python
Write-Output "Upgrading pip..."
& .\.venv\Scripts\python.exe -m pip install --upgrade pip
# Install required packages
Write-Output "Installing toml package..."
& .\.venv\Scripts\python.exe -m pip install toml
# Generate requirements.txt
Write-Output "Running gen_req.py to generate requirements.txt..."
try {
& .\.venv\Scripts\python.exe gen_req.py
}
catch {
Write-Output "Failed to run gen_req.py"
exit 1
}
# Install dependencies
Write-Output "Installing dependencies..."
& .\.venv\Scripts\python.exe -m pip install -r requirements.txt
Write-Output "Environment setup is complete."