Skip to content

Commit c9fdda3

Browse files
authored
refactor(): use choco for python (#42)
Install python, 2 and 3, through chocolatey.
1 parent 8566c6d commit c9fdda3

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

WebKitDev/Functions/Install-Python.ps1

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,28 @@ function Install-Python {
3535
)
3636

3737
$major,$minor,$patch = $version.split('.');
38+
$packageParameters = @();
39+
40+
if ($installationPath) {
41+
$packageParameters += ('/InstallDir:"{0}"' -f $installationPath)
42+
}
3843

3944
if ($major -ne '2') {
40-
$pythonUrl = ('https://www.python.org/ftp/python/{0}/python-{0}-amd64.exe' -f $version);
45+
$name = ('python{0}{1}' -f $major,$minor);
4146
$getPip = 'https://bootstrap.pypa.io/get-pip.py';
42-
43-
$options = @(
44-
'/quiet',
45-
'InstallAllUsers=1',
46-
'PrependPath=1',
47-
'AssociateFiles=0'
48-
);
49-
50-
if ($installationPath) {
51-
$options += ('TargetDir="{0}"' -f $installationPath)
52-
}
53-
54-
Install-FromExe -Name 'python' -url $pythonUrl -Options $options;
5547
}
5648
else {
57-
$pythonUrl = ('https://www.python.org/ftp/python/{0}/python-{0}.amd64.msi' -f $version);
49+
$name = 'python2'
5850
$getPip = 'https://bootstrap.pypa.io/pip/2.7/get-pip.py';
59-
60-
$options = @(
61-
'ALLUSERS=1',
62-
'ADDLOCAL=DefaultFeature,Extensions,TclTk,Tools,PrependPath'
63-
);
64-
65-
if ($installationPath) {
66-
$options += ('TARGETDIR="{0}"' -f $installationPath);
67-
}
68-
69-
Install-FromMsi -Name 'python' -url $pythonUrl -Options $options;
7051
}
7152

53+
# Install Python
54+
Install-FromChoco `
55+
-Name $name `
56+
-Version $version `
57+
-VerifyExe 'python' `
58+
-PackageParameters $packageParameters;
59+
7260
# Install PIP
7361
$pipInstall = ('pip=={0}' -f $pipVersion);
7462
Write-Information -MessageData ('Installing {0} from {1} ...' -f ($pipInstall,$getPip)) -InformationAction Continue;

0 commit comments

Comments
 (0)