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) { async function findPython(binDir?: string) {
if (binDir !== undefined) { const foundBins = (
for (const pythonBinPath of ["python3", "python"]) { await Promise.all(
// eslint-disable-next-line no-await-in-loop ["python3", "python"].map(async (pythonBin) => {
if (await pathExists(join(binDir, addExeExt(pythonBinPath)))) { try {
return pythonBinPath if (binDir !== undefined) {
} if (
} (await pathExists(join(binDir, addExeExt(pythonBin)))) &&
} (await isBinUptoDate(pythonBin, DefaultVersions.python!))
if (which.sync("python3", { nothrow: true }) !== null) { ) {
return "python3" return pythonBin
} else if (which.sync("python", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) { }
return "python" }
} if (
return undefined (await which(pythonBin, { nothrow: true })) !== null &&
(await isBinUptoDate(pythonBin, DefaultVersions.python!))
) {
return pythonBin
}
} catch {
// ignore
}
return undefined
})
)
).filter((bin) => bin !== undefined)
return foundBins?.[0]
} }
async function findOrSetupPip(foundPython: string) { async function findOrSetupPip(foundPython: string) {
@ -154,16 +167,22 @@ async function findOrSetupPip(foundPython: string) {
} }
async function findPip() { async function findPip() {
for (const pip of ["pip3", "pip"]) { const foundBins = (
if ( await Promise.all(
which.sync(pip, { nothrow: true }) !== null && ["pip3", "pip"].map(async (pip) => {
// eslint-disable-next-line no-await-in-loop try {
(await isBinUptoDate(pip, DefaultVersions.pip!)) if ((await which(pip, { nothrow: true })) !== null && (await isBinUptoDate(pip, DefaultVersions.pip!))) {
) { return pip
return pip }
} } catch {
} // ignore
return undefined }
return undefined
})
)
).filter((bin) => bin !== undefined)
return foundBins?.[0]
} }
async function setupPip(foundPython: string) { 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/ 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 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", pip: "22.3.1",
python: "3.8.0", // min version
} }
/// If an ubuntu versions is not in this map: /// If an ubuntu versions is not in this map: