@@ -798,79 +798,72 @@ function Fetch-Dependencies {
798
798
New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \toolchains | Out-Null
799
799
Extract- Toolchain " $PinnedToolchain .exe" $BinaryCache $PinnedToolchain
800
800
801
- function Download-Python ($ArchName ) {
802
- $PythonAMD64URL = " https://www.nuget.org/api/v2/package/python/$PythonVersion "
803
- $PythonAMD64Hash = " ac43b491e9488ac926ed31c5594f0c9409a21ecbaf99dc7a93f8c7b24cf85867"
804
-
805
- $PythonARM64URL = " https://www.nuget.org/api/v2/package/pythonarm64/$PythonVersion "
806
- $PythonARM64Hash = " 429ada77e7f30e4bd8ff22953a1f35f98b2728e84c9b1d006712561785641f69"
807
-
808
- DownloadAndVerify (Get-Variable - Name " Python${ArchName} URL" ).Value $BinaryCache \Python$ArchName - $PythonVersion.zip (Get-Variable - Name " Python${ArchName} Hash" ).Value
801
+ function Install-Python ([string ] $ArchName ) {
802
+ $Python = @ {
803
+ AMD64 = @ {
804
+ URL = " https://www.nuget.org/api/v2/package/python/$PythonVersion " ;
805
+ SHA256 = " ac43b491e9488ac926ed31c5594f0c9409a21ecbaf99dc7a93f8c7b24cf85867" ;
806
+ };
807
+ ARM64 = @ {
808
+ URL = " https://www.nuget.org/api/v2/package/pythonarm64/$PythonVersion " ;
809
+ SHA256 = " 429ada77e7f30e4bd8ff22953a1f35f98b2728e84c9b1d006712561785641f69" ;
810
+ }
811
+ }
809
812
813
+ DownloadAndVerify $Python [$ArchName ].URL " $BinaryCache \Python$ArchName -$PythonVersion .zip" $Python [$ArchName ].SHA256
810
814
if (-not $ToBatch ) {
811
- Extract- ZipFile Python$ArchName - $PythonVersion.zip $BinaryCache Python$ArchName - $PythonVersion
815
+ Extract- ZipFile Python$ArchName - $PythonVersion.zip " $BinaryCache " Python$ArchName - $PythonVersion
812
816
}
813
817
}
814
818
815
- function Ensure-PythonModules ($Python ) {
816
- # First ensure pip is installed, else bootstrap it
819
+ function Install-PythonWheel ([string ] $ModuleName , [string ] $WheelFile , [string ] $WheelURL , [string ] $WheelHash ) {
817
820
try {
818
- Invoke-Program - OutNull $Python - m pip * > $null
821
+ Invoke-Program " $ ( Get-PythonExecutable ) " - c " import $ModuleName " * > $null
819
822
} catch {
820
- Write-Output " Installing pip ..."
821
- Invoke-Program - OutNull $Python ' -I' - m ensurepip - U -- default- pip
823
+ DownloadAndVerify $WheelURL " $BinaryCache \python\$WheelFile " $WheelHash
824
+ Write-Output " Installing '$WheelFile ' ..."
825
+ Invoke-Program - OutNull " $ ( Get-PythonExecutable ) " ' -I' - m pip install " $BinaryCache \python\$WheelFile " -- disable-pip - version- check
822
826
}
823
- # 'packaging' is required for building LLVM 18+
827
+ }
828
+
829
+ function Install-PythonModules () {
830
+ # First ensure pip is installed, else bootstrap it
824
831
try {
825
- Invoke-Program - OutNull $Python - c ' import packaging ' * > $null
832
+ Invoke-Program " $ ( Get-PythonExecutable ) " - m pip * > $null
826
833
} catch {
827
- $WheelURL = " https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl"
828
- $WheelHash = " 5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"
829
- DownloadAndVerify $WheelURL " $BinaryCache \python\packaging-24.1-py3-none-any.whl" $WheelHash
830
- Write-Output " Installing 'packaging-24.1-py3-none-any.whl' ..."
831
- Invoke-Program - OutNull $Python ' -I' - m pip install " $BinaryCache \python\packaging-24.1-py3-none-any.whl" -- disable-pip - version- check
834
+ Write-Output " Installing pip ..."
835
+ Invoke-Program - OutNull " $ ( Get-PythonExecutable ) " ' -I' - m ensurepip - U -- default- pip
832
836
}
837
+
838
+ # 'packaging' is required for building LLVM 18+
839
+ Install-PythonWheel ' packaging' ' packaging-24.1-py3-none-any.whl' `
840
+ ' https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl' `
841
+ ' 5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124'
842
+
833
843
# 'setuptools' provides 'distutils' module for Python 3.12+, required for SWIG support
834
- # https://github.com/swiftlang/llvm-project/issues/9289
835
- try {
836
- Invoke-Program - OutNull $Python - c ' import distutils' * > $null
837
- } catch {
838
- $WheelURL = " https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl"
839
- $WheelHash = " 35ab7fd3bcd95e6b7fd704e4a1539513edad446c097797f2985e0e4b960772f2"
840
- DownloadAndVerify $WheelURL " $BinaryCache \python\setuptools-75.1.0-py3-none-any.whl" $WheelHash
841
- Write-Output " Installing 'setuptools-75.1.0-py3-none-any.whl' ..."
842
- Invoke-Program - OutNull $Python ' -I' - m pip install " $BinaryCache \python\setuptools-75.1.0-py3-none-any.whl" -- disable-pip - version- check
843
- }
844
+ Install-PythonWheel ' distutils' ' setuptools-75.1.0-py3-none-any.whl' `
845
+ ' https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl' `
846
+ ' 35ab7fd3bcd95e6b7fd704e4a1539513edad446c097797f2985e0e4b960772f2'
847
+
844
848
if ($Test -contains " lldb" ) {
845
849
# 'psutil' is required for testing LLDB
846
- try {
847
- Invoke-Program - OutNull $Python - c ' import psutil' * > $null
848
- } catch {
849
- $WheelURL = " https://files.pythonhosted.org/packages/11/91/87fa6f060e649b1e1a7b19a4f5869709fbf750b7c8c262ee776ec32f3028/psutil-6.1.0-cp37-abi3-win_amd64.whl"
850
- $WheelHash = " a8fb3752b491d246034fa4d279ff076501588ce8cbcdbb62c32fd7a377d996be"
851
- DownloadAndVerify $WheelURL " $BinaryCache \python\psutil-6.1.0-cp37-abi3-win_amd64.whl" $WheelHash
852
- Write-Output " Installing 'psutil-6.1.0-cp37-abi3-win_amd64.whl' ..."
853
- Invoke-Program - OutNull $Python ' -I' - m pip install " $BinaryCache \python\psutil-6.1.0-cp37-abi3-win_amd64.whl" -- disable-pip - version- check
854
- }
850
+ Install-PythonWheel ' psutil' ' psutil-6.1.0-cp37-abi3-win_amd64.whl' `
851
+ ' https://files.pythonhosted.org/packages/11/91/87fa6f060e649b1e1a7b19a4f5869709fbf750b7c8c262ee776ec32f3028/psutil-6.1.0-cp37-abi3-win_amd64.whl' `
852
+ ' a8fb3752b491d246034fa4d279ff076501588ce8cbcdbb62c32fd7a377d996be'
853
+
855
854
# 'unittest2' is required for testing LLDB
856
- try {
857
- Invoke-Program - OutNull $Python - c ' import unittest2' * > $null
858
- } catch {
859
- $WheelURL = " https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl"
860
- $WheelHash = " 13f77d0875db6d9b435e1d4f41e74ad4cc2eb6e1d5c824996092b3430f088bb8"
861
- DownloadAndVerify $WheelURL " $BinaryCache \python\unittest2-1.1.0-py2.py3-none-any.whl" $WheelHash
862
- Write-Output " Installing 'unittest2-1.1.0-py2.py3-none-any.whl' ..."
863
- Invoke-Program - OutNull $Python ' -I' - m pip install " $BinaryCache \python\unittest2-1.1.0-py2.py3-none-any.whl" -- disable-pip - version- check
864
- }
855
+ Install-PythonWheel ' unittest2' ' unittest2-1.1.0-py2.py3-none-any.whl' `
856
+ ' https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl' `
857
+ ' 13f77d0875db6d9b435e1d4f41e74ad4cc2eb6e1d5c824996092b3430f088bb8'
865
858
}
866
859
}
867
860
868
- Download - Python $HostArchName
861
+ Install -Python $HostArchName
869
862
if ($IsCrossCompiling ) {
870
- Download - Python $BuildArchName
863
+ Install -Python $BuildArchName
871
864
}
872
865
# Ensure Python modules that are required as host build tools
873
- Ensure - PythonModules " $ ( Get-PythonExecutable ) "
866
+ Install -PythonModules
874
867
875
868
if ($Android ) {
876
869
# Only a specific NDK version is supported right now.
0 commit comments