From acf7a56b310a1e42036b4a64d9036c2ebb8f22dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 19 Oct 2023 16:45:36 +0200 Subject: [PATCH] Use given PYTHON env variable (if given) when running worker/scripts/getmake.py (#1186) --- CHANGELOG.md | 1 + npm-scripts.mjs | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5f49e6839..cde1b12781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### NEXT * CI: Use Node.js version 20 ([PR #1177](https://github.com/versatica/mediasoup/pull/1177)). +* Use given `PYTHON` environment variable (if given) when running `worker/scripts/getmake.py` ([PR #1186](https://github.com/versatica/mediasoup/pull/1186)). ### 3.12.13 diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 433d309d1b..7ca9942e75 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -418,21 +418,34 @@ function installMsysMake() { logInfo('installMsysMake()'); - let res = spawnSync('where', [ 'python3.exe' ]); + let pythonPath; - if (res.status !== 0) + // If PYTHON environment variable is given, use it. + if (process.env.PYTHON) { - res = spawnSync('where', [ 'python.exe' ]); + pythonPath = process.env.PYTHON; + } + // Otherwise ensure python3.exe is available in the PATH. + else + { + let res = spawnSync('where', [ 'python3.exe' ]); if (res.status !== 0) { - logError('`installMsysMake() | cannot find Python executable'); + res = spawnSync('where', [ 'python.exe' ]); - exitWithError(); + if (res.status !== 0) + { + logError('`installMsysMake() | cannot find Python executable'); + + exitWithError(); + } } + + pythonPath = String(res.stdout).trim(); } - executeCmd(`${String(res.stdout).trim()} worker\\scripts\\getmake.py`); + executeCmd(`${pythonPath} worker\\scripts\\getmake.py`); } function ensureDir(dir)