fix: parallel findPython and findPip

This commit is contained in:
Amin Yahyaabadi 2023-06-28 16:19:00 -07:00
parent f708497511
commit 9aecf4658e
6 changed files with 48 additions and 28 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -124,20 +124,33 @@ async function setupPythonSystem(setupDir: string, version: string) {
}
async function findPython(binDir?: string) {
const foundBins = (
await Promise.all(
["python3", "python"].map(async (pythonBin) => {
try {
if (binDir !== undefined) {
for (const pythonBinPath of ["python3", "python"]) {
// eslint-disable-next-line no-await-in-loop
if (await pathExists(join(binDir, addExeExt(pythonBinPath)))) {
return pythonBinPath
if (
(await pathExists(join(binDir, addExeExt(pythonBin)))) &&
(await isBinUptoDate(pythonBin, DefaultVersions.python!))
) {
return pythonBin
}
}
if (
(await which(pythonBin, { nothrow: true })) !== null &&
(await isBinUptoDate(pythonBin, DefaultVersions.python!))
) {
return pythonBin
}
if (which.sync("python3", { nothrow: true }) !== null) {
return "python3"
} else if (which.sync("python", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
return "python"
} catch {
// ignore
}
return undefined
})
)
).filter((bin) => bin !== undefined)
return foundBins?.[0]
}
async function findOrSetupPip(foundPython: string) {
@ -154,16 +167,22 @@ async function findOrSetupPip(foundPython: string) {
}
async function findPip() {
for (const pip of ["pip3", "pip"]) {
if (
which.sync(pip, { nothrow: true }) !== null &&
// eslint-disable-next-line no-await-in-loop
(await isBinUptoDate(pip, DefaultVersions.pip!))
) {
const foundBins = (
await Promise.all(
["pip3", "pip"].map(async (pip) => {
try {
if ((await which(pip, { nothrow: true })) !== null && (await isBinUptoDate(pip, DefaultVersions.pip!))) {
return pip
}
} catch {
// ignore
}
return undefined
})
)
).filter((bin) => bin !== undefined)
return foundBins?.[0]
}
async function setupPip(foundPython: string) {

View File

@ -29,6 +29,7 @@ export const DefaultVersions: Record<string, string | undefined> = {
doxygen: isArch() ? "1.9.6-1" : "1.9.7", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
gcc: isArch() ? "13.1.1-1" : "13", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
pip: "22.3.1",
python: "3.8.0", // min version
}
/// If an ubuntu versions is not in this map: