Skip to content

Commit 69759fe

Browse files
committed
Create a PS1/BAT script to install Python and the EBCLI
The PS1 script invokes: - install-python.ps1 - ebcli_installer.py if the Python installer exists with code 0 The PS1 script installs instructs ebcli_installer.py to install `eb` in the user's home directory (within a .ebcli-virtual-env folder). The BAT script wraps the PS1 script.
1 parent db8262f commit 69759fe

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

scripts/bundled_installer.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Powershell.exe -executionpolicy remotesigned -File "%~dp0\bundled_installer.ps1"

scripts/bundled_installer.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
function Write-OutputWithInvertedColors([String] $Message) {
2+
Write-Host $Message -ForegroundColor Black -BackgroundColor White
3+
}
4+
5+
function Get-HomePath() {
6+
if (Test-Path Env:\USERPROFILE) {
7+
return $env:USERPROFILE
8+
} elseif (Test-Path Env:\HOMEDRIVE -and Env:\HOMEPATH) {
9+
return $env:HOMEDRIVE + $env:HOMEPATH
10+
} elseif (Test-Path Env:\LOCALAPPDATA) {
11+
return $env:LOCALAPPDATA
12+
} elseif (Test-Path Env:\APPDATA) {
13+
return $env:APPDATA
14+
} else {
15+
Write-Host "Cannot determine user's home directory." -ForegroundColor Red
16+
Exit 1
17+
}
18+
}
19+
20+
function Exit-OnFailure() {
21+
if ($LASTEXITCODE -ne 0) {
22+
Write-Host "Exiting due to failure" -ForegroundColor Red
23+
exit 1
24+
}
25+
}
26+
27+
function Update-UserEnvironmentPath {
28+
$env:Path =
29+
[System.Environment]::GetEnvironmentVariable("Path","Machine") +
30+
";" +
31+
[System.Environment]::GetEnvironmentVariable("Path","User")
32+
}
33+
34+
function Write-StepTitle([String] $Message) {
35+
$equals = "=" * 46
36+
Write-Host ""
37+
Write-OutputWithInvertedColors $equals
38+
Write-OutputWithInvertedColors $Message
39+
Write-OutputWithInvertedColors $equals
40+
}
41+
Write-StepTitle "I. Installing Python "
42+
powershell "$PSScriptRoot\install-python.ps1"
43+
Exit-OnFailure
44+
Update-UserEnvironmentPath
45+
46+
Write-StepTitle "II. Creating self-contained EBCLI installation"
47+
$HomeDir = Get-HomePath
48+
Write-Host "Installing the EBCLI in $HomeDir\.ebcli-virtual-env"
49+
python "$PSScriptRoot\ebcli_installer.py" --virtualenv-executable "$PSScriptRoot\virtualenv\bin\virtualenv.exe" --hide-export-recommendation --location $HomeDir
50+
Exit-OnFailure
51+
52+
$PathExporter = "$HomeDir\.ebcli-virtual-env\executables\path_exporter.vbs"
53+
if ([System.IO.File]::Exists($PathExporter)) {
54+
Write-StepTitle "III. Exporting `eb` PATH's "
55+
& "$HomeDir\.ebcli-virtual-env\executables\path_exporter.vbs"
56+
Update-UserEnvironmentPath
57+
}

0 commit comments

Comments
 (0)