File: install_python.ps1

package info (click to toggle)
imath 3.1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,468 kB
  • sloc: cpp: 44,687; ansic: 171; sh: 153; python: 60; makefile: 32
file content (37 lines) | stat: -rwxr-xr-x 1,209 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
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.

$homeDir = (pwd)

$pythonVersion = $Args[0]
$pythonWorkingDir = $Args[1]

$pythonMajor = ($pythonVersion -split '\.')[0]
$pythonMinor = ($pythonVersion -split '\.')[1]
$pythonRoot = "${pythonWorkingDir}\_python${pythonMajor}${pythonMinor}"

Write-Host "Installing python version ${pythonVersion} ${pythonRoot}"

if (-NOT (Test-Path $pythonRoot))
{
	New-Item -ItemType Directory $pythonRoot
}

cd $pythonRoot

if ($pythonMajor -eq "3")
{
    Invoke-WebRequest "https://www.python.org/ftp/python/${pythonVersion}/python-${pythonVersion}.exe" -OutFile "python-${pythonVersion}-amd64.exe"
    Invoke-Expression "./python-${pythonVersion}-amd64.exe /quiet /l* _python.log TargetDir=${pythonRoot} PrependPath=1"
}
else
{
    Invoke-WebRequest "https://www.python.org/ftp/python/${pythonVersion}/python-${pythonVersion}.amd64.msi" -OutFile "python-${pythonVersion}-amd64.msi"
    msiexec /i "python-${pythonVersion}-amd64.msi" /quiet /l* _python.log TARGETDIR="${pythonRoot}" PrependPath=1
}

cd $homeDir

echo "::set-env name=PYTHON_ROOT::$pythonRoot"
echo "::add-path::$pythonRoot"
echo "::add-path::$pythonRoot/Scripts"