Skip to content

Commit 9aecf46

Browse files
committed
fix: parallel findPython and findPip
1 parent f708497 commit 9aecf46

File tree

6 files changed

+48
-28
lines changed

6 files changed

+48
-28
lines changed

dist/node12/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node12/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/python/python.ts

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,33 @@ async function setupPythonSystem(setupDir: string, version: string) {
124124
}
125125

126126
async function findPython(binDir?: string) {
127-
if (binDir !== undefined) {
128-
for (const pythonBinPath of ["python3", "python"]) {
129-
// eslint-disable-next-line no-await-in-loop
130-
if (await pathExists(join(binDir, addExeExt(pythonBinPath)))) {
131-
return pythonBinPath
132-
}
133-
}
134-
}
135-
if (which.sync("python3", { nothrow: true }) !== null) {
136-
return "python3"
137-
} else if (which.sync("python", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
138-
return "python"
139-
}
140-
return undefined
127+
const foundBins = (
128+
await Promise.all(
129+
["python3", "python"].map(async (pythonBin) => {
130+
try {
131+
if (binDir !== undefined) {
132+
if (
133+
(await pathExists(join(binDir, addExeExt(pythonBin)))) &&
134+
(await isBinUptoDate(pythonBin, DefaultVersions.python!))
135+
) {
136+
return pythonBin
137+
}
138+
}
139+
if (
140+
(await which(pythonBin, { nothrow: true })) !== null &&
141+
(await isBinUptoDate(pythonBin, DefaultVersions.python!))
142+
) {
143+
return pythonBin
144+
}
145+
} catch {
146+
// ignore
147+
}
148+
return undefined
149+
})
150+
)
151+
).filter((bin) => bin !== undefined)
152+
153+
return foundBins?.[0]
141154
}
142155

143156
async function findOrSetupPip(foundPython: string) {
@@ -154,16 +167,22 @@ async function findOrSetupPip(foundPython: string) {
154167
}
155168

156169
async function findPip() {
157-
for (const pip of ["pip3", "pip"]) {
158-
if (
159-
which.sync(pip, { nothrow: true }) !== null &&
160-
// eslint-disable-next-line no-await-in-loop
161-
(await isBinUptoDate(pip, DefaultVersions.pip!))
162-
) {
163-
return pip
164-
}
165-
}
166-
return undefined
170+
const foundBins = (
171+
await Promise.all(
172+
["pip3", "pip"].map(async (pip) => {
173+
try {
174+
if ((await which(pip, { nothrow: true })) !== null && (await isBinUptoDate(pip, DefaultVersions.pip!))) {
175+
return pip
176+
}
177+
} catch {
178+
// ignore
179+
}
180+
return undefined
181+
})
182+
)
183+
).filter((bin) => bin !== undefined)
184+
185+
return foundBins?.[0]
167186
}
168187

169188
async function setupPip(foundPython: string) {

src/versions/default_versions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const DefaultVersions: Record<string, string | undefined> = {
2929
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/
3030
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
3131
pip: "22.3.1",
32+
python: "3.8.0", // min version
3233
}
3334

3435
/// If an ubuntu versions is not in this map:

0 commit comments

Comments
 (0)