-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
setup.ps1
84 lines (76 loc) · 2.96 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
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
Write-Host " __ ______________ __ __ ___
/ |/ / ____/ ___/___ ______ _____ _____/ / ____ ___ ______ _____/ /_ ___ _____ |__ \
/ /|_/ / / \__ \/ _ \/ ___/ | / / _ \/ ___/ / / __ `/ / / / __ \/ ___/ __ \/ _ \/ ___/ __/ /
/ / / / /___ ___/ / __/ / | |/ / __/ / / /___/ /_/ / /_/ / / / / /__/ / / / __/ / / __/
/_/ /_/\____//____/\___/_/ |___/\___/_/ /_____/\__,_/\__,_/_/ /_/\___/_/ /_/\___/_/ /____/
-----------------------------------------------------------------------------------------------------
Installation Script"
###################################
# Select Python
###################################
$existPythonList = Get-Command python -All | Select-Object -ExpandProperty Source
$selectedPython = $null
while ($selectedPython -eq $null) {
Write-Host "Choose Python version, required version: >=3.8,<3.9 :"
$i = 1
$existPythonList | ForEach-Object {
Write-Host "$i. $_"
$i++
}
$choice = Read-Host -Prompt "Enter the number of the desired Python version"
if ($choice -ge 1 -and $choice -le $existPythonList.Count) {
$selectedPython = $existPythonList[$choice - 1]
}
else {
Write-Host "Invalid selection. Please enter a valid number."
}
}
###################################
# Check PDM
###################################
$pdmInstall = Read-Host -Prompt "Have you installed pdm? We need this to install dependencies. (y/n)"
if ($pdmInstall -eq "n") {
$pipxUsage = Read-Host -Prompt "Do you want to use pipx to install pdm (Recommended)? (y/n)"
if ($pipxUsage -eq "y") {
$pipxInstall = Read-Host -Prompt "Have you installed pipx? If no, we will help you do this. (y/n)"
if ($pipxInstall -eq "n") {
Write-Host "Installing pipx..."
& $selectedPython -m pip install --user pipx
& $selectedPython -m pipx ensurepath
Write-Host "pipx has been installed. You need to re-open this terminal and re-run this script to continue."
exit
}
else {
& $selectedPython -m pipx install pdm
Write-Host "pdm has been installed successfully with pipx."
}
}
else {
& $selectedPython -m pip install --user pdm
Write-Host "pdm has been installed successfully with pip."
}
}
###################################
# Venv
###################################
$useVenv = Read-Host -Prompt "Do you want a virtual environment? (y/n)"
if ($useVenv -eq "n") {
& pdm use $selectedPython
}
else {
& pdm venv create $selectedPython
& pdm use --venv in-project
}
###################################
# Install dependencies
###################################
Write-Host "Installing dependencies..."
$isDev = Read-Host -Prompt "Do you want to install dev dependencies? (y/n)"
if ($isDev -eq "y") {
& pdm install --no-self --dev
}
else {
& pdm install --no-self
}
Write-Host "Success."
exit