@@ -121,15 +121,14 @@ async function setupPythonSystem(setupDir: string, version: string) {
121121}
122122
123123async function findPython ( binDir ?: string ) {
124- const foundBins = (
125- await Promise . all ( [ "python3" , "python" ] . map ( ( pythonBin ) => isPythonUpToDate ( pythonBin , binDir ) ) )
126- ) . filter ( ( bin ) => bin !== undefined ) as string [ ]
127-
128- if ( foundBins . length === 0 ) {
129- return undefined
124+ for ( const pythonBin of [ "python3" , "python" ] ) {
125+ // eslint-disable-next-line no-await-in-loop
126+ const foundPython = await isPythonUpToDate ( pythonBin , binDir )
127+ if ( foundPython !== undefined ) {
128+ return foundPython
129+ }
130130 }
131-
132- return foundBins [ 0 ]
131+ return undefined
133132}
134133
135134async function isPythonUpToDate ( candidate : string , binDir ?: string ) {
@@ -142,9 +141,12 @@ async function isPythonUpToDate(candidate: string, binDir?: string) {
142141 }
143142 }
144143 }
145- const pythonBinPath : string | null = await which ( candidate , { nothrow : true } )
146- if ( pythonBinPath !== null && ( await isBinUptoDate ( pythonBinPath , MinVersions . python ! ) ) ) {
147- return pythonBinPath
144+ const pythonBinPaths = ( await which ( candidate , { nothrow : true , all : true } ) ) ?? [ ]
145+ for ( const pythonBinPath of pythonBinPaths ) {
146+ // eslint-disable-next-line no-await-in-loop
147+ if ( await isBinUptoDate ( pythonBinPath , MinVersions . python ! ) ) {
148+ return pythonBinPath
149+ }
148150 }
149151 } catch {
150152 // fall through
@@ -166,22 +168,24 @@ async function findOrSetupPip(foundPython: string) {
166168}
167169
168170async function findPip ( ) {
169- const foundBins = ( await Promise . all ( [ "pip3" , "pip" ] . map ( isPipUptoDate ) ) ) . filter (
170- ( bin ) => bin !== undefined
171- ) as string [ ]
172-
173- if ( foundBins . length === 0 ) {
174- return undefined
171+ for ( const pipCandidate of [ "pip3" , "pip" ] ) {
172+ // eslint-disable-next-line no-await-in-loop
173+ const maybePip = await isPipUptoDate ( pipCandidate )
174+ if ( maybePip !== undefined ) {
175+ return maybePip
176+ }
175177 }
176-
177- return foundBins [ 0 ]
178+ return undefined
178179}
179180
180181async function isPipUptoDate ( pip : string ) {
181182 try {
182- const pipPath : string | null = await which ( pip , { nothrow : true } )
183- if ( pipPath !== null && ( await isBinUptoDate ( pipPath , MinVersions . pip ! ) ) ) {
184- return pipPath
183+ const pipPaths = ( await which ( pip , { nothrow : true , all : true } ) ) ?? [ ]
184+ for ( const pipPath of pipPaths ) {
185+ // eslint-disable-next-line no-await-in-loop
186+ if ( pipPath !== null && ( await isBinUptoDate ( pipPath , MinVersions . pip ! ) ) ) {
187+ return pipPath
188+ }
185189 }
186190 } catch {
187191 // fall through
0 commit comments