mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-11 19:05:35 +08:00
fix(postgresql): provision meson, ninja and winflexbison on windows
- the meson build assumed meson/ninja/win_flex/win_bison/perl on PATH, which only held on machines that had them installed - add meson, ninja and winflexbison tool packages and declare them via tools@windows on postgresql, together with the existing strawberry-perl - meson no longer ships a Windows MSI, so the wheel is installed offline into a venv: postgres re-invokes meson through find_program, which needs the real meson.exe launcher pip generates
This commit is contained in:
45
src/Package/Artifact/meson_win.php
Normal file
45
src/Package/Artifact/meson_win.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Artifact;
|
||||
|
||||
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
class meson_win
|
||||
{
|
||||
/**
|
||||
* Meson 1.11 dropped the Windows MSI, so the artifact is the wheel, installed offline
|
||||
* into a private venv. The venv is not just packaging hygiene: pip generates a real
|
||||
* meson.exe launcher there, and PostgreSQL needs one because its build re-invokes meson
|
||||
* through find_program(), which rejects non-executables like the meson.pyz zipapp.
|
||||
*/
|
||||
#[AfterBinaryExtract('meson', ['windows-x86_64'])]
|
||||
public function afterExtract(string $target_path): void
|
||||
{
|
||||
$dir = dirname($target_path);
|
||||
$venv = "{$dir}\\venv";
|
||||
|
||||
$python = null;
|
||||
foreach (['python', 'py -3'] as $candidate) {
|
||||
[$code] = cmd()->execWithResult("{$candidate} --version", false);
|
||||
if ($code === 0) {
|
||||
$python = $candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($python === null) {
|
||||
throw new EnvironmentException('meson needs Python 3 on PATH. Install it from https://www.python.org or with `winget install Python.Python.3.13`.');
|
||||
}
|
||||
|
||||
if (is_dir($venv)) {
|
||||
FileSystem::removeDir($venv);
|
||||
}
|
||||
cmd()->exec("{$python} -m venv \"{$venv}\"")
|
||||
->exec("\"{$venv}\\Scripts\\python.exe\" -m pip install --no-index --no-deps \"{$target_path}\"");
|
||||
|
||||
FileSystem::writeFile("{$dir}\\meson.bat", "@echo off\r\n\"%~dp0venv\\Scripts\\meson.exe\" %*\r\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user