Merge branch 'create_script'
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# Python-Environment-Setup
|
||||
|
||||
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`
|
||||
|
||||
19
git.inf
Normal file
19
git.inf
Normal file
@@ -0,0 +1,19 @@
|
||||
[Setup]
|
||||
Lang=default
|
||||
Dir=C:\Program Files\Git
|
||||
Group=Git
|
||||
NoIcons=0
|
||||
SetupType=default
|
||||
Components=gitlfs,assoc,consolefont,autoupdate
|
||||
Tasks=
|
||||
EditorOption=VisualStudioCode
|
||||
CustomEditorPath=
|
||||
PathOption=Cmd
|
||||
SSHOption=OpenSSH
|
||||
TortoiseOption=false
|
||||
CURLOption=WinSSL
|
||||
CRLFOption=LFOnly
|
||||
BashTerminalOption=MinTTY
|
||||
PerformanceTweaksFSCache=Enabled
|
||||
UseCredentialManager=Enabled
|
||||
EnableSymlinks=Disabled
|
||||
63
setup.ps1
Normal file
63
setup.ps1
Normal file
@@ -0,0 +1,63 @@
|
||||
#Weird stuff happens with IE compatibility mode set, especially if you're working remotely. Temporarily turn off compatibility mode for intranet sites
|
||||
$reg_path = "HKCU:\SOFTWARE\Microsoft\Internet Explorer\BrowserEmulation"
|
||||
$cur_compat_mode = Get-ItemProperty -Path $reg_path -Name IntranetCompatibilityMode | Select-Object -ExpandProperty IntranetCompatibilityMode
|
||||
New-ItemProperty -Path $reg_path -Name IntranetCompatibilityMode -Value 0 -Force | Out-Null
|
||||
#now that compatibility mode is off temporarily, we can scrape the web
|
||||
|
||||
$default_install_paths = $HOME, $env:ProgramFiles
|
||||
|
||||
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
|
||||
|
||||
if ($conda_installed) {
|
||||
write-host "
|
||||
You appear to have Anaconda or Miniconda installed already.
|
||||
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()
|
||||
$install_miniconda = ("y","yes") -contains $user_input
|
||||
}
|
||||
else{
|
||||
Write-Host "No Anaconda or Miniconda installation detected.`n"
|
||||
}
|
||||
|
||||
if ($install_miniconda) {
|
||||
#Setup Miniconda
|
||||
Write-Host "Installing Miniconda...`n`n"
|
||||
$miniconda_url = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
|
||||
$miniconda_installer = $miniconda_url.split('/')[-1]
|
||||
|
||||
#Silent mode command line flags: https://docs.anaconda.com/anaconda/install/silent-mode/
|
||||
$miniconda_install_params = '/S', '/D="$HOME\Miniconda3"', '/InstallationType=JustMe', '/RegisterPython=0', '/AddToPath=0'
|
||||
Invoke-WebRequest $miniconda_url -OutFile $miniconda_installer
|
||||
Invoke-Expression "& .\$miniconda_installer $miniconda_install_params"
|
||||
#Remove-Item ".\$miniconda_installer"
|
||||
$conda_exe = "$HOME\Miniconda3\Scripts\conda.exe"
|
||||
#Make conda accessible from any/all shells
|
||||
Invoke-Expression "& $conda_exe init --all"
|
||||
}
|
||||
|
||||
if (-Not (Test-Path "$HOME\AppData\Local\Programs\Microsoft VS Code\Code.exe")){
|
||||
#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"
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((Test-Path "$env:LOCALAPPDATA\Programs\Git\bin\git.exe") -or (Test-Path "$env:ProgramFiles\Git\bin\git.exe")){
|
||||
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