1
1
[String ] $Architecture = " {{__ARCHITECTURE__}}"
2
+ [String ] $HardwareArchitecture = " {{__HARDWARE_ARCHITECTURE__}}"
2
3
[String ] $Version = " {{__VERSION__}}"
3
4
[String ] $PythonExecName = " {{__PYTHON_EXEC_NAME__}}"
4
5
@@ -25,7 +26,7 @@ function Remove-RegistryEntries {
25
26
[Parameter (Mandatory )][Int32 ] $MinorVersion
26
27
)
27
28
28
- $versionFilter = Get-RegistryVersionFilter - Architecture $Architecture - MajorVersion $MajorVersion - MinorVersion $MinorVersion
29
+ $versionFilter = Get-RegistryVersionFilter - Architecture $HardwareArchitecture - MajorVersion $MajorVersion - MinorVersion $MinorVersion
29
30
30
31
$regPath = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
31
32
if (Test-Path - Path Registry::$regPath ) {
@@ -61,13 +62,15 @@ function Remove-RegistryEntries {
61
62
function Get-ExecParams {
62
63
param (
63
64
[Parameter (Mandatory )][Boolean ] $IsMSI ,
65
+ [Parameter (Mandatory )][Boolean ] $IsFreeThreaded ,
64
66
[Parameter (Mandatory )][String ] $PythonArchPath
65
67
)
66
68
67
69
if ($IsMSI ) {
68
70
" TARGETDIR=$PythonArchPath ALLUSERS=1"
69
71
} else {
70
- " DefaultAllUsersTargetDir=$PythonArchPath InstallAllUsers=1"
72
+ $Include_freethreaded = if ($IsFreeThreaded ) { " Include_freethreaded=1" } else { " " }
73
+ " DefaultAllUsersTargetDir=$PythonArchPath InstallAllUsers=1 $Include_freethreaded "
71
74
}
72
75
}
73
76
@@ -81,6 +84,7 @@ $PythonVersionPath = Join-Path -Path $PythonToolcachePath -ChildPath $Version
81
84
$PythonArchPath = Join-Path - Path $PythonVersionPath - ChildPath $Architecture
82
85
83
86
$IsMSI = $PythonExecName -match " msi"
87
+ $IsFreeThreaded = $Architecture -match " -freethreaded"
84
88
85
89
$MajorVersion = $Version.Split (' .' )[0 ]
86
90
$MinorVersion = $Version.Split (' .' )[1 ]
@@ -120,13 +124,24 @@ Write-Host "Copy Python binaries to $PythonArchPath"
120
124
Copy-Item - Path ./ $PythonExecName - Destination $PythonArchPath | Out-Null
121
125
122
126
Write-Host " Install Python $Version in $PythonToolcachePath ..."
123
- $ExecParams = Get-ExecParams - IsMSI $IsMSI - PythonArchPath $PythonArchPath
127
+ $ExecParams = Get-ExecParams - IsMSI $IsMSI - IsFreeThreaded $IsFreeThreaded - PythonArchPath $PythonArchPath
124
128
125
129
cmd.exe / c " cd $PythonArchPath && call $PythonExecName $ExecParams /quiet"
126
130
if ($LASTEXITCODE -ne 0 ) {
127
131
Throw " Error happened during Python installation"
128
132
}
129
133
134
+ # print out all files in $PythonArchPath
135
+ Write-Host " Files in $PythonArchPath "
136
+ $files = Get-ChildItem - Path $PythonArchPath - File - Recurse
137
+ Write-Output $files
138
+
139
+ if ($IsFreeThreaded ) {
140
+ # Delete python.exe and create a symlink to free-threaded exe
141
+ Remove-Item - Path " $PythonArchPath \python.exe" - Force
142
+ New-Item - Path " $PythonArchPath \python.exe" - ItemType SymbolicLink - Value " $PythonArchPath \python${MajorVersion} .${MinorVersion} t.exe"
143
+ }
144
+
130
145
Write-Host " Create `python3` symlink"
131
146
if ($MajorVersion -ne " 2" ) {
132
147
New-Item - Path " $PythonArchPath \python3.exe" - ItemType SymbolicLink - Value " $PythonArchPath \python.exe"
0 commit comments