feat(tool): bundle python for the meson build

- add a python-win tool package that unzips the official python.org
  nuget package into the pkgroot (venv and ensurepip included)
- meson uses it to build its venv and only falls back to a system
  python, so no manual environment setup is needed
This commit is contained in:
m-this
2026-07-08 14:17:36 +02:00
parent 43b2da0511
commit d7902b9931
4 changed files with 80 additions and 2 deletions

View File

@@ -22,8 +22,11 @@ class meson_win
$dir = dirname($target_path);
$venv = "{$dir}\\venv";
// Prefer the python-win tool package (installed alongside via tools@windows),
// fall back to whatever Python the machine already has.
$candidates = ['"' . PKG_ROOT_PATH . '\python-win\tools\python.exe"', 'python', 'py -3'];
$python = null;
foreach (['python', 'py -3'] as $candidate) {
foreach ($candidates as $candidate) {
[$code] = cmd()->execWithResult("{$candidate} --version", false);
if ($code === 0) {
$python = $candidate;
@@ -31,7 +34,7 @@ class meson_win
}
}
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`.');
throw new EnvironmentException('meson needs Python 3; the python-win tool package did not install and no system Python was found.');
}
if (is_dir($venv)) {