-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.ps1
56 lines (50 loc) · 1.1 KB
/
setup.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
[CmdletBinding()]
param (
[Parameter()]
[string]
$Command = "deps"
)
# Check if OS is Windows
if ($env:OS -ne "Windows_NT") {
Write-Host "This script is only for Windows"
exit
}
# Variables
$VENV = ".venv"
function CreateEnv {
if (-not (Test-Path $VENV)) {
python -m venv $VENV
}
}
function InstallDependencies {
# Activate virtual environment
. $VENV\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
}
# Switch over provided command
switch ($Command) {
"venv" {
CreateEnv
break
}
"deps" {
CreateEnv
InstallDependencies
break
}
"clean" {
if (Test-Path $VENV) {
. $VENV\Scripts\Deactivate.ps1 2>$null
Remove-Item -Recurse -Force $VENV
Write-Host "Virtual environment removed successfully"
}
else {
Write-Host "Virtual environment does not exist"
}
}
default {
Write-Host "Invalid command ($Command): Supported commands are 'venv', 'deps', 'clean'"
}
}