Skip to content

Commit e5965e3

Browse files
committed
Install required pip packages into Windows Python builds
1 parent 9373421 commit e5965e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

install-python.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
$versions = "3.8.10","3.9.13","3.10.11","3.11.9","3.12.7","3.13.0"
66
$installerargs = "/quiet","/repair","InstallAllUsers=0","Include_doc=0","Include_pip=0","Include_test=0","Include_launcher=0","Include_freethreaded=1","InstallLauncherAllUsers=0","Shortcuts=0","AssociateFiles=0"
7+
$packages = "pytest","pip","setuptools"
78

89
$temp = Join-Path ([System.IO.Path]::GetTempPath()) $(New-Guid)
910
New-Item -Type Directory -Path $temp | Out-Null
@@ -18,6 +19,8 @@ if ($args[0] -match '64$')
1819
$dirsuffix = "-x64"
1920
}
2021

22+
$env:PYTHONDONTWRITEBYTECODE = "1"
23+
2124
foreach ($version in $versions)
2225
{
2326
$url = "https://www.python.org/ftp/python/$version/python-$version$installersuffix.exe"
@@ -46,6 +49,13 @@ foreach ($version in $versions)
4649
Start-Process -Wait $installer -ArgumentList ($installerargs+"TargetDir=$installdir")
4750
}
4851

52+
Write-Host "Installing pip packages..."
53+
Start-Process -Wait $installdir\python.exe -NoNewWindow -ArgumentList "-B","-m","ensurepip"
54+
Start-Process -Wait $installdir\python.exe -NoNewWindow -ArgumentList (@("-B","-m","pip","install")+$packages)
55+
56+
Write-Host "Deleting __pycache__ directories..."
57+
Get-ChildItem $installdir -Include __pycache__ -Recurse -Force | Remove-Item -Force -Recurse
58+
4959
Write-Host "Copying to $destination..."
5060
if (Test-Path $destination)
5161
{

0 commit comments

Comments
 (0)