Skip to content

Commit

Permalink
let's try
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Oct 17, 2024
1 parent 323222e commit eb8040c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,19 @@ function installPythonDeps() {

// Install PIP deps into custom location, so we don't depend on system-wide
// installation.
executeCmd(
`"${PYTHON}" -m pip install --upgrade --no-user --target="${PIP_DEPS_DIR}" --break-system-packages worker/`,
/* exitOnError */ true
// However this may fail due to different PIP and OS versions, so let's do a
// best effort.
const res = executeCmd(
`"${PYTHON}" -m pip install --upgrade --no-user --target="${PIP_DEPS_DIR}" ${args} worker/`,
/* exitOnError */ false
);

if (!res) {
executeCmd(
`"${PYTHON}" -m pip install --upgrade --no-user --target="${PIP_DEPS_DIR}" ${args} --break-system-packages worker/`,
/* exitOnError */ true
);
}
}

function installPythonDevDeps() {
Expand Down Expand Up @@ -275,18 +284,28 @@ function checkRelease() {
}
}

/**
* Returns true if the command succeeded, 0 otherwise.
*
* If exitOnError is set and command fails, then process is terminated with
* error.
*/
function executeCmd(command, exitOnError = true) {
logInfo(`executeCmd(): ${command}`);

try {
execSync(command, { stdio: ['ignore', process.stdout, process.stderr] });

return true;
} catch (error) {
if (exitOnError) {
logError(`executeCmd() failed, exiting: ${error}`);

exitWithError();
} else {
logInfo(`executeCmd() failed, ignoring: ${error}`);

return false;
}
}
}
Expand Down

0 comments on commit eb8040c

Please sign in to comment.