File: install.ps1

package info (click to toggle)
python-quamash 0.6.1~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 204 kB
  • sloc: python: 1,290; sh: 4; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,535 bytes parent folder | download | duplicates (2)
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
# Adapted from Sample script to install Python and pip under Windows
# Authors: Olivier Grisel and Kyle Kastner
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
# Adapted by Mark Harviston <mark.harviston@gmail.com>

$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
$GET_PIP_PATH = "C:\get-pip.py"

function InstallPip ($python_home) {
	$pip_path = $python_home + "\Scripts\pip.exe"
	$python_path = $python_home + "\python.exe"
	if (-not(Test-Path $pip_path)) {
		Write-Host "Installing pip..."
		$webclient = New-Object System.Net.WebClient
		$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
		Write-Host "Executing:" $python_path $GET_PIP_PATH
		Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru
	} else {
		Write-Host "pip already installed."
	}
}

function InstallPackage ($python_home, $pkg) {
	$pip_path = $python_home + "\Scripts\pip.exe"
	& $pip_path install --only-binary=PySide --only-binary=PyQt4 --only-binary=PyQt5 --find-links .\wheelhouse $pkg
}

function main () {
	$PYTHON_MAJ_VERSION = $env:PYTHON_VERSION -replace '(\d+)\.(\d+)\.(\d+)', '$1.$2'
	& REG ADD "HKCU\Software\Python\PythonCore\${PYTHON_MAJ_VERSION}\InstallPath" /f /ve /t REG_SZ /d $env:PYTHON
	InstallPip $env:PYTHON
	InstallPackage $env:PYTHON wheel
	InstallPackage $env:PYTHON pytest
	switch ($env:QTIMPL){
		"PySide" {
			InstallPackage $env:Python PySide
		}
		"PyQt4" {
			InstallPackage $env:Python PyQt4
		}
		"PyQt5" {
			InstallPackage $env:Python PyQt5
		}
	}
}

main