-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows.ps1
144 lines (126 loc) · 5.92 KB
/
windows.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
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
143
144
Clear-Host
$version="2.0.0"
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version distribution installer"
Get-Content .\ascii-art.ans
Start-Sleep -Seconds 2
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version distribution installer"
Write-Output "Here is every module that is available in the distribution."
Write-Output "The Language and Editor modules are mandatory. Every other module is optional and will be prompted to you."
Get-Content .\doc\DOWNLOADS.txt
Pause
Function Test-CommandExists
{
Param ($command)
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = "stop"
try {if(Get-Command $command){"$command exists"}}
Catch {"$command does not exist"}
Finally {$ErrorActionPreference=$oldPreference}
}
function pyinstall() {
Write-Host -ForegroundColor Blue "Installing Python 3.12.1"
$installer_url="https://www.python.org/ftp/python/3.12.1/python-3.12.1-amd64.exe"
Invoke-WebRequest -URI $installer_url -OutFile "tmp/python_installer.exe"
tmp/python_installer.exe /passive AppendPath=1
Pause
}
function vscinstall() {
Write-Host -ForegroundColor Blue "Installing Visual Studio Code"
$installer_url="https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user"
Invoke-WebRequest -URI $installer_url -OutFile "tmp/vscode_installer.exe"
tmp/vscode_installer.exe /SILENT /NOCANCEL
}
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version > Language > Python 3.12.1"
If(-not (Test-CommandExists "py")) {
pyinstall
} Else {
Write-Host -ForegroundColor Green "A version of Python is already installed:"
py -V
$confirmation = Read-Host -Prompt "Would you like to install Python 3.12.1?`n[type YES (case-sensitive) to confirm, anything else if not]"
If($confirmation -eq "YES") {
pyinstall
}
}
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version > Editor > Visual Studio Code"
If(-not (Test-CommandExists "code")) {
vscinstall
} Else {
Write-Host -ForegroundColor Green "Visual Studio Code is already installed."
}
Pause
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version > Editor > Python extension"
$l = $(code --list-extensions)
If($l -notcontains "ms-python.python") {
code --install-extension "ms-python.python"
} Else {
Write-Host -ForegroundColor Green "Python for VSC is already installed."
}
Pause
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version > Language > pip libraries"
Write-Host -ForegroundColor DarkBlue "Here are the available modules:"
ForEach($item in $(Get-ChildItem .\pip)) {
Write-Host -NoNewline "$($item.Name) "
}
Write-Host "`n"
$modules = Read-Host -Prompt "Please type in all of the modules that you would like to install.`nYou must separate them using a space.`nExample: type 'gui tui' if you only want the gui and tui modules.`nIf you want all modules, type *`n[Modules]"
$execute = $true
If($modules -ne "*") {
$module_selections = $modules.Split(" ")
} ElseIf ($modules -eq "") {
$execute = $false
} Else {
$module_selections = Get-ChildItem .\pip
}
If($execute -eq $true) {
ForEach($selected_module in $module_selections) {
Clear-Host
Write-Host -BackgroundColor DarkBlue "mipy $version > Language > pip libraries > $selected_module"
If(Test-Path "$PSScriptRoot/$selected_module") {
Write-Host -ForegroundColor Blue "Libraries to install:"
Get-Content "$PSScriptRoot/$selected_module"
Write-Output ""
py -m pip install -r "$PSScriptRoot/$selected_module"
Write-Host -ForegroundColor Green "Module $PSScriptRoot/$selected_module installed!"
} else {
Write-Host -ForegroundColor Red "Module $PSScriptRoot/$selected_module wasn't found. You can always install individual libraries later."
}
Start-Sleep -Seconds 1
}
}
Clear-Host
Write-Host -ForegroundColor Green "mipy $version was successfully installed!"
Write-Host -ForegroundColor Blue "Here are some tips to get you started:"
Write-Host -ForegroundColor Gray -NoNewline "To open a folder, use "
Write-Host -ForegroundColor White -NoNewline "Visual Studio Code"
Write-Host -ForegroundColor Gray -NoNewline " or run the terminal command "
Write-Host -ForegroundColor Magenta -NoNewline "code path/to/workspace"
Write-Host -ForegroundColor Gray "."
Write-Host -ForegroundColor Gray -NoNewline "Python also bundles the "
Write-Host -ForegroundColor White -NoNewline "IDLE"
Write-Host -ForegroundColor Gray -NoNewline " editor, which you can run directly or using the command "
Write-Host -ForegroundColor Magenta -NoNewline "python -m idlelib path/to/script"
Write-Host -ForegroundColor Gray "."
Write-Host -ForegroundColor Gray -NoNewline "To run a Python file from VS Code, use "
Write-Host -ForegroundColor White -NoNewline "fn + f5 (or f5 if your computer doesn't have an fn key)"
Write-Host -ForegroundColor Gray -NoNewline " or from the command line "
Write-Host -ForegroundColor Magenta -NoNewline "py path/to/file"
Write-Host -ForegroundColor Gray "."
Write-Host -ForegroundColor Gray -NoNewline "If you want to install Python libraries, use "
Write-Host -ForegroundColor Magenta -NoNewline "pip install name_of_library"
Write-Host -ForegroundColor Gray "."
Write-Host -ForegroundColor Gray -NoNewline "If you want to upgrade Python libraries, use "
Write-Host -ForegroundColor Magenta -NoNewline "pip install --upgrade name_of_library"
Write-Host -ForegroundColor Gray "."
Write-Host -ForegroundColor Gray -NoNewline "If you want to remove Python libraries, use "
Write-Host -ForegroundColor Magenta -NoNewline "pip uninstall name_of_library"
Write-Host -ForegroundColor Gray "."
Write-Host -ForegroundColor Gray -NoNewline "If you want to see all Python libraries, use "
Write-Host -ForegroundColor Magenta -NoNewline "pip list"
Write-Host -ForegroundColor Gray "."
Pause