@@ -338,26 +338,50 @@ $KnownPythons = @{
338
338
}
339
339
}
340
340
341
- $PythonWheels = @ {
341
+ $PythonModules = @ {
342
342
" 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
+ };
346
352
};
347
353
" 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
+ };
351
363
};
352
364
" 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
+ };
356
374
};
357
375
" 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
+ }
361
385
};
362
386
}
363
387
@@ -1007,27 +1031,47 @@ function Get-Dependencies {
1007
1031
}
1008
1032
}
1009
1033
1010
- function Install-PythonWheel ([string ] $ModuleName ) {
1034
+ function Is-Python-Module-Installed ([string ] $ModuleName ) {
1011
1035
try {
1012
1036
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
1013
1057
} 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
1018
1062
} finally {
1019
1063
Write-Output " $ModuleName installed."
1020
1064
}
1021
1065
}
1022
1066
1023
1067
function Install-PythonModules () {
1024
1068
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
1027
1071
if ($Test -contains " lldb" ) {
1028
- Install-PythonWheel " psutil" # Required for testing LLDB
1072
+ Install-PythonModule " psutil" # Required for testing LLDB
1029
1073
$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
1031
1075
}
1032
1076
}
1033
1077
0 commit comments