finished initial draft of script, needs testing
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
# Python-Environment-Setup
|
# Python-Environment-Setup
|
||||||
|
|
||||||
This script will setup Miniconda, Visual Studio Code, and Git for you
|
This script will setup Miniconda, Visual Studio Code, and Git for you
|
||||||
|
|
||||||
|
To run this setup script, from a command line, change to the directory that contains the script and run `powershell -File .\setup.ps1`
|
||||||
|
|||||||
50
setup.ps1
50
setup.ps1
@@ -4,33 +4,28 @@ $cur_compat_mode = Get-ItemProperty -Path $reg_path -Name IntranetCompatibilityM
|
|||||||
New-ItemProperty -Path $reg_path -Name IntranetCompatibilityMode -Value 0 -Force | Out-Null
|
New-ItemProperty -Path $reg_path -Name IntranetCompatibilityMode -Value 0 -Force | Out-Null
|
||||||
#now that compatibility mode is off temporarily, we can scrape the web
|
#now that compatibility mode is off temporarily, we can scrape the web
|
||||||
|
|
||||||
$default_install_paths = $HOME, $env:LOCALAPPDATA, $env:ProgramFiles
|
$default_install_paths = $HOME, $env:ProgramFiles
|
||||||
|
|
||||||
$conda_installed = $default_install_paths | ForEach-Object -Process { Get-ChildItem | Where-Object -Property "Name" -Like -Value "*conda*" }
|
Write-Host "Checking for existing installations of Anaconda or Miniconda. This may take a few minutes..."
|
||||||
|
$conda_installed = $default_install_paths | ForEach-Object -Process {Get-ChildItem -Recurse -File -Force -Filter conda.exe -ErrorAction SilentlyContinue | Select-Object -First 1}
|
||||||
|
|
||||||
$install_miniconda = -not $conda_installed
|
$install_miniconda = -Not $conda_installed
|
||||||
|
|
||||||
if ($conda_installed) {
|
if ($conda_installed) {
|
||||||
write-host "
|
write-host "
|
||||||
Found some files that indicate you may already have an Anaconda/Miniconda environment installed.
|
You appear to have Anaconda or Miniconda installed already.
|
||||||
|
|
||||||
$($default_install_paths |
|
|
||||||
ForEach-Object -Process {Get-ChildItem |
|
|
||||||
Where-Object -Property "Name" -Like -Value "*conda*" |
|
|
||||||
ForEach-Object -Process {$_.FullName |
|
|
||||||
ForEach-Object -Process {$_ + "`n "}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Installing Miniconda on top of it may have unintended side-effects of breaking your existing installation.
|
Installing Miniconda on top of it may have unintended side-effects of breaking your existing installation.
|
||||||
"
|
"
|
||||||
$user_input = (Read-Host -Prompt "Continue Installation of Miniconda anyway? [yes|(no)] ").ToLower()
|
$user_input = (Read-Host -Prompt "Continue Installation of Miniconda anyway? [yes|(no)] ").ToLower()
|
||||||
$install_miniconda = ("y","yes") -contains $user_input
|
$install_miniconda = ("y","yes") -contains $user_input
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
Write-Host "No Anaconda or Miniconda installation detected.`n"
|
||||||
|
}
|
||||||
|
|
||||||
if ($install_miniconda) {
|
if ($install_miniconda) {
|
||||||
#Setup Miniconda
|
#Setup Miniconda
|
||||||
|
Write-Host "Installing Miniconda...`n`n"
|
||||||
$miniconda_url = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
|
$miniconda_url = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
|
||||||
$miniconda_installer = $miniconda_url.split('/')[-1]
|
$miniconda_installer = $miniconda_url.split('/')[-1]
|
||||||
|
|
||||||
@@ -44,10 +39,25 @@ if ($install_miniconda) {
|
|||||||
Invoke-Expression "& $conda_exe init --all"
|
Invoke-Expression "& $conda_exe init --all"
|
||||||
}
|
}
|
||||||
|
|
||||||
#Setup Visual Studio Code
|
if (-Not (Test-Path "$HOME\AppData\Local\Programs\Microsoft VS Code\Code.exe")){
|
||||||
$vscode_url = "https://aka.ms/win32-x64-user-stable"
|
#Setup Visual Studio Code
|
||||||
|
Write-Host "Installing Microsoft Visual Studio Code...`n`n"
|
||||||
|
$vscode_url = "https://aka.ms/win32-x64-user-stable"
|
||||||
|
((Invoke-WebRequest -Method Head $vscode_url).Headers["Content-Disposition"]) -match '"(.+)"' | Out-Null
|
||||||
|
$vscode_installer = $Matches[1]
|
||||||
|
Invoke-WebRequest $vscode_url -OutFile $vscode_installer
|
||||||
|
Invoke-Expression "& .\$vscode_installer /VERYSILENT /LOADINF=.\vscode.inf"
|
||||||
|
}
|
||||||
|
|
||||||
$git_url = Invoke-WebRequest "https://git-scm.com/download/win" | Select-Object -ExpandProperty Links | Where-Object innerText -like "64-bit Git for Windows Setup" | Select-Object -ExpandProperty href
|
|
||||||
$git_installer = $git_url.split('/')[-1]
|
|
||||||
Invoke-WebRequest $git_url -OutFile $git_installer
|
if ((Test-Path "$env:LOCALAPPDATA\Programs\Git\bin\git.exe") -or (Test-Path "$env:ProgramFiles\Git\bin\git.exe")){
|
||||||
Invoke-Expression "& .\$git_installer /VERYSILENT /LOADINF=.\git.inf"
|
Write-Host "Installing Git...`n`n"
|
||||||
|
$git_url = Invoke-WebRequest "https://git-scm.com/download/win" | Select-Object -ExpandProperty Links | Where-Object innerText -like "64-bit Git for Windows Setup" | Select-Object -ExpandProperty href
|
||||||
|
$git_installer = $git_url.split('/')[-1]
|
||||||
|
Invoke-WebRequest $git_url -OutFile $git_installer
|
||||||
|
Invoke-Expression "& .\$git_installer /VERYSILENT /LOADINF=.\git.inf"
|
||||||
|
}
|
||||||
|
|
||||||
|
#restore IE compatibility mode setting
|
||||||
|
New-ItemProperty -Path $reg_path -Name IntranetCompatibilityMode -Value $cur_compat_mode -Force | Out-Null
|
||||||
|
|||||||
6
vscode.inf
Normal file
6
vscode.inf
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Setup]
|
||||||
|
Lang=english
|
||||||
|
Dir=%LOCALAPPDATA%\Programs\Microsoft VS Code
|
||||||
|
Group=Visual Studio Code
|
||||||
|
NoIcons=0
|
||||||
|
Tasks=desktopicon,addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath
|
||||||
Reference in New Issue
Block a user