Created
December 16, 2016 09:01
-
-
Save msnelling/49f222f5d608c55b1537639e86599645 to your computer and use it in GitHub Desktop.
Installs Miniconda from extracted .exe installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$Exe7z, | |
[string]$PackageDir, | |
[string]$InstallDir | |
) | |
Function Expand-ToDirectory { | |
param( | |
[string]$Archive, | |
[string]$TargetDir | |
) | |
Write-Host "INFO: Expanding $Archive to $TargetDir" | |
& $Exe7z x -aoa -bd $Archive -o"$TargetDir" > null | |
If ($LASTEXITCODE -ne 0) { | |
Throw "Failed to expand $Archive to $TargetDir with error code $LASTEXITCODE" | |
} | |
} | |
Function Install-MinicondaPackage { | |
param([string]$Package) | |
Write-Host "INFO: Installing package $Package" | |
Expand-ToDirectory -Archive $Package -TargetDir $InstallDir | |
& "$InstallDir\python.exe" -E -s "$InstallDir\pkgs\.install.py" --root-prefix "$InstallDir" --post root | |
If ($LASTEXITCODE -ne 0) { | |
Throw "Failed to install $Package with error code $LASTEXITCODE" | |
} | |
} | |
Write-Host "INFO: Creating $InstallDir" | |
New-Item -Type Directory $InstallDir -Force | Out-Null | |
Write-Host "INFO: Copying $PackageDir\Lib to $InstallDir" | |
Copy-Item "$PackageDir\Lib" $InstallDir -Recurse -Container -Force | Out-Null | |
Write-Host "INFO: Expanding tar.bz2 files" | |
Expand-ToDirectory -Archive "$PackageDir\preconda.tar.bz2" -TargetDir $PackageDir | |
Expand-ToDirectory -Archive "$PackageDir\preconda.tar" -TargetDir $InstallDir | |
Expand-ToDirectory -Archive "$PackageDir\pkgs\*.bz2" -TargetDir "$PackageDir\pkgs" | |
Write-Host "INFO: Getting list of packages" | |
$Packages = Get-ChildItem "$PackageDir\pkgs" -Filter *.tar | Select-Object -ExpandProperty FullName | |
Write-Host "INFO: Bootstrapping Python" | |
Expand-ToDirectory -Archive ($Packages -like '*vs*_runtime*') -TargetDir $InstallDir | |
Install-MinicondaPackage -Package ($Packages -like '*python*') | |
Write-Host "INFO: Installing packages" | |
$Packages -notlike '*python*' | %{Install-MinicondaPackage -Package $_} | |
Write-Host "INFO: Running post-install scripts" | |
& "$InstallDir\python.exe" -E -s "$InstallDir\Lib\_nsis.py" mkdirs | |
& "$InstallDir\python.exe" -E -s "$InstallDir\Lib\_nsis.py" addpath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment