Skip to content

Commit 5106db2

Browse files
committed
Install python when config.w32 uses PYTHONHOME
1 parent da488d4 commit 5106db2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

extension/BuildPhpExtension/private/Add-BuildTools.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,30 @@ Function Add-BuildTools {
3232
choco install git.install --params "'/GitAndUnixToolsOnPath /WindowsTerminal /NoAutoCrlf'" -y --force
3333
}
3434
Default {
35+
$program = $_
3536
$resultLines = (choco search $_ --limit-output) -split "\`r?\`n"
36-
if($resultLines | Where-Object { $_ -match "^$_\|" }) {
37+
if($resultLines | Where-Object { $_ -match "^$program\|" }) {
3738
choco install $_ -y --force
3839
}
3940
}
4041
}
42+
} else {
43+
switch ($_)
44+
{
45+
# Check if python is actually installed.
46+
python {
47+
$pythonVersion = python --version 2>&1
48+
if($pythonVersion -match "not found") {
49+
choco install python -y --force
50+
}
51+
$pythonPath = (Get-Command python).Source
52+
$pythonHome = Split-Path $pythonPath
53+
[Environment]::SetEnvironmentVariable("PYTHONPATH", $pythonPATH, [System.EnvironmentVariableTarget]::User)
54+
$env:PYTHONPATH = $pythonPath
55+
[Environment]::SetEnvironmentVariable("PYTHONHOME", $pythonHome, [System.EnvironmentVariableTarget]::User)
56+
$env:PYTHONHOME = $pythonHome
57+
}
58+
}
4159
}
4260
}
4361
}

extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ Function Get-ExtensionConfig {
176176
$config.build_tools += $_.Groups[2].Value
177177
}
178178
}
179+
if($configW32Content.contains('PYTHONHOME')) {
180+
$config.build_tools += "python"
181+
}
179182

180183
$config.build_directory = if ($Arch -eq "x64") { "x64\" } else { "" }
181184
$config.build_directory += "Release"

0 commit comments

Comments
 (0)