Skip to content

Commit ffd801b

Browse files
[windows] add backup pip install when no wheels are available
1 parent f59f602 commit ffd801b

File tree

1 file changed

+66
-22
lines changed

1 file changed

+66
-22
lines changed

utils/build.ps1

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -338,26 +338,50 @@ $KnownPythons = @{
338338
}
339339
}
340340

341-
$PythonWheels = @{
341+
$PythonModules = @{
342342
"packaging" = @{
343-
File = "packaging-24.1-py3-none-any.whl";
344-
URL = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl";
345-
SHA256 = "5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124";
343+
Wheel = @{
344+
File = "packaging-24.1-py3-none-any.whl";
345+
URL = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl";
346+
SHA256 = "5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124";
347+
};
348+
Module = @{
349+
Version = "24.1";
350+
SHA256 = "026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002";
351+
};
346352
};
347353
"distutils" = @{
348-
File = "setuptools-75.1.0-py3-none-any.whl";
349-
URL = "https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl";
350-
SHA256 = "35ab7fd3bcd95e6b7fd704e4a1539513edad446c097797f2985e0e4b960772f2";
354+
Wheel = @{
355+
File = "setuptools-75.1.0-py3-none-any.whl";
356+
URL = "https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl";
357+
SHA256 = "35ab7fd3bcd95e6b7fd704e4a1539513edad446c097797f2985e0e4b960772f2";
358+
};
359+
Module = @{
360+
Version = "75.1.0";
361+
SHA256 = "d59a21b17a275fb872a9c3dae73963160ae079f1049ed956880cd7c09b120538";
362+
};
351363
};
352364
"psutil" = @{
353-
File = "psutil-6.1.0-cp37-abi3-win_amd64.whl";
354-
URL = "https://files.pythonhosted.org/packages/11/91/87fa6f060e649b1e1a7b19a4f5869709fbf750b7c8c262ee776ec32f3028/psutil-6.1.0-cp37-abi3-win_amd64.whl";
355-
SHA256 = "a8fb3752b491d246034fa4d279ff076501588ce8cbcdbb62c32fd7a377d996be";
365+
Wheel = @{
366+
File = "psutil-6.1.0-cp37-abi3-win_amd64.whl";
367+
URL = "https://files.pythonhosted.org/packages/11/91/87fa6f060e649b1e1a7b19a4f5869709fbf750b7c8c262ee776ec32f3028/psutil-6.1.0-cp37-abi3-win_amd64.whl";
368+
SHA256 = "a8fb3752b491d246034fa4d279ff076501588ce8cbcdbb62c32fd7a377d996be";
369+
};
370+
Module = @{
371+
Version = "6.1.0";
372+
SHA256 = "353815f59a7f64cdaca1c0307ee13558a0512f6db064e92fe833784f08539c7a";
373+
};
356374
};
357375
"unittest2" = @{
358-
File = "unittest2-1.1.0-py2.py3-none-any.whl";
359-
URL = "https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl";
360-
SHA256 = "13f77d0875db6d9b435e1d4f41e74ad4cc2eb6e1d5c824996092b3430f088bb8";
376+
Wheel = @{
377+
File = "unittest2-1.1.0-py2.py3-none-any.whl";
378+
URL = "https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl";
379+
SHA256 = "13f77d0875db6d9b435e1d4f41e74ad4cc2eb6e1d5c824996092b3430f088bb8";
380+
};
381+
Module = @{
382+
Version = "1.1.0";
383+
SHA256 = "22882a0e418c284e1f718a822b3b022944d53d2d908e1690b319a9d3eb2c0579";
384+
}
361385
};
362386
}
363387

@@ -1007,27 +1031,47 @@ function Get-Dependencies {
10071031
}
10081032
}
10091033

1010-
function Install-PythonWheel([string] $ModuleName) {
1034+
function Is-Python-Module-Installed([string] $ModuleName) {
10111035
try {
10121036
Invoke-Program -Silent "$(Get-PythonExecutable)" -c "import $ModuleName"
1037+
return $true;
1038+
} catch {
1039+
return $false;
1040+
}
1041+
}
1042+
1043+
function Install-PythonWheel([string] $ModuleName) {
1044+
$Wheel = $PythonModules[$ModuleName]["Wheel"]
1045+
DownloadAndVerify $Wheel.URL "$BinaryCache\python\$($Wheel.File)" $Wheel.SHA256
1046+
Write-Output "Installing '$($Wheel.File)' ..."
1047+
Invoke-Program -OutNull "$(Get-PythonExecutable)" '-I' -m pip install "$BinaryCache\python\$($Wheel.File)" --disable-pip-version-check
1048+
}
1049+
1050+
function Install-PythonModule([string] $ModuleName) {
1051+
if (Is-Python-Module-Installed $ModuleName) {
1052+
Write-Output "$ModuleName already installed."
1053+
return;
1054+
}
1055+
try {
1056+
Install-PythonWheel $ModuleName
10131057
} catch {
1014-
$Wheel = $PythonWheels[$ModuleName]
1015-
DownloadAndVerify $Wheel.URL "$BinaryCache\python\$($Wheel.File)" $Wheel.SHA256
1016-
Write-Output "Installing '$($Wheel.File)' ..."
1017-
Invoke-Program -OutNull "$(Get-PythonExecutable)" '-I' -m pip install "$BinaryCache\python\$($Wheel.File)" --disable-pip-version-check
1058+
$TempRequirementsTxt = New-TemporaryFile
1059+
$Module = $PythonModules[$ModuleName]["Module"]
1060+
Write-Output "$ModuleName==$($Module.Version) --hash=`"sha256:$($Module.SHA256)`"" >> $TempRequirementsTxt
1061+
Invoke-Program -OutNull "$(Get-PythonExecutable)" '-I' -m pip install -r $TempRequirementsTxt --require-hashes --no-binary==:all: --disable-pip-version-check
10181062
} finally {
10191063
Write-Output "$ModuleName installed."
10201064
}
10211065
}
10221066

10231067
function Install-PythonModules() {
10241068
Install-PIPIfNeeded
1025-
Install-PythonWheel "packaging" # For building LLVM 18+
1026-
Install-PythonWheel "distutils" # Required for SWIG support
1069+
Install-PythonModule "packaging" # For building LLVM 18+
1070+
Install-PythonModule "distutils" # Required for SWIG support
10271071
if ($Test -contains "lldb") {
1028-
Install-PythonWheel "psutil" # Required for testing LLDB
1072+
Install-PythonModule "psutil" # Required for testing LLDB
10291073
$env:Path = "$(Get-PythonScriptsPath);$env:Path" # For unit.exe
1030-
Install-PythonWheel "unittest2" # Required for testing LLDB
1074+
Install-PythonModule "unittest2" # Required for testing LLDB
10311075
}
10321076
}
10331077

0 commit comments

Comments
 (0)