Skip to content

Commit

Permalink
Install python when config.w32 uses PYTHONHOME
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Aug 22, 2024
1 parent da488d4 commit 5106db2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 19 additions & 1 deletion extension/BuildPhpExtension/private/Add-BuildTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,30 @@ Function Add-BuildTools {
choco install git.install --params "'/GitAndUnixToolsOnPath /WindowsTerminal /NoAutoCrlf'" -y --force
}
Default {
$program = $_
$resultLines = (choco search $_ --limit-output) -split "\`r?\`n"
if($resultLines | Where-Object { $_ -match "^$_\|" }) {
if($resultLines | Where-Object { $_ -match "^$program\|" }) {
choco install $_ -y --force
}
}
}
} else {
switch ($_)
{
# Check if python is actually installed.
python {
$pythonVersion = python --version 2>&1
if($pythonVersion -match "not found") {
choco install python -y --force
}
$pythonPath = (Get-Command python).Source
$pythonHome = Split-Path $pythonPath
[Environment]::SetEnvironmentVariable("PYTHONPATH", $pythonPATH, [System.EnvironmentVariableTarget]::User)
$env:PYTHONPATH = $pythonPath
[Environment]::SetEnvironmentVariable("PYTHONHOME", $pythonHome, [System.EnvironmentVariableTarget]::User)
$env:PYTHONHOME = $pythonHome
}
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ Function Get-ExtensionConfig {
$config.build_tools += $_.Groups[2].Value
}
}
if($configW32Content.contains('PYTHONHOME')) {
$config.build_tools += "python"
}

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

0 comments on commit 5106db2

Please sign in to comment.