@@ -3,7 +3,7 @@ import { getExecOutput } from "@actions/exec"
3
3
import assert from "assert"
4
4
import { GITHUB_ACTIONS } from "ci-info"
5
5
import { info , warning } from "ci-log"
6
- import { execaSync } from "execa"
6
+ import { execa } from "execa"
7
7
import memoize from "micro-memoize"
8
8
import { addExeExt , dirname , join } from "patha"
9
9
import which from "which"
@@ -21,6 +21,7 @@ import { isBinUptoDate } from "../utils/setup/version"
21
21
import { unique } from "../utils/std"
22
22
import { MinVersions } from "../versions/default_versions"
23
23
import { pathExists } from "path-exists"
24
+ import { setupPipPackWithPython } from "../utils/setup/setupPipPack"
24
25
25
26
export async function setupPython ( version : string , setupDir : string , arch : string ) : Promise < InstallationInfo > {
26
27
const installInfo = await findOrSetupPython ( version , setupDir , arch )
@@ -33,11 +34,12 @@ export async function setupPython(version: string, setupDir: string, arch: strin
33
34
throw new Error ( "pip was not installed correctly" )
34
35
}
35
36
36
- // setup wheel
37
+ // setup wheel and setuptools
37
38
try {
38
- setupWheel ( foundPython )
39
+ await setupPipPackWithPython ( foundPython , "setuptools" , undefined , true )
40
+ await setupPipPackWithPython ( foundPython , "wheel" , undefined , true )
39
41
} catch ( err ) {
40
- warning ( `Failed to install wheels : ${ ( err as Error ) . toString ( ) } . Ignoring...` )
42
+ warning ( `Failed to install setuptools or wheel : ${ ( err as Error ) . toString ( ) } . Ignoring...` )
41
43
}
42
44
43
45
return installInfo
@@ -99,6 +101,11 @@ async function setupPythonSystem(setupDir: string, version: string) {
99
101
}
100
102
case "darwin" : {
101
103
installInfo = await setupBrewPack ( "python3" , version )
104
+ // add the python and pip binaries to the path
105
+ const brewPythonPrefix = await execa ( "brew" , [ "--prefix" , "python" ] , { stdio : "pipe" } )
106
+ const brewPythonBin = join ( brewPythonPrefix . stdout , "libexec" , "bin" )
107
+ await addPath ( brewPythonBin )
108
+
102
109
break
103
110
}
104
111
case "linux" : {
@@ -107,7 +114,7 @@ async function setupPythonSystem(setupDir: string, version: string) {
107
114
} else if ( hasDnf ( ) ) {
108
115
installInfo = setupDnfPack ( "python3" , version )
109
116
} else if ( isUbuntu ( ) ) {
110
- installInfo = await setupAptPack ( [ { name : "python3" , version } ] )
117
+ installInfo = await setupAptPack ( [ { name : "python3" , version } , { name : "python-is-python3" } ] )
111
118
} else {
112
119
throw new Error ( "Unsupported linux distributions" )
113
120
}
@@ -194,23 +201,23 @@ async function isPipUptoDate(pip: string) {
194
201
}
195
202
196
203
async function setupPip ( foundPython : string ) {
197
- const upgraded = ensurePipUpgrade ( foundPython )
204
+ const upgraded = await ensurePipUpgrade ( foundPython )
198
205
if ( ! upgraded ) {
199
206
await setupPipSystem ( )
200
207
// upgrade pip
201
- ensurePipUpgrade ( foundPython )
208
+ await ensurePipUpgrade ( foundPython )
202
209
}
203
210
}
204
211
205
- function ensurePipUpgrade ( foundPython : string ) {
212
+ async function ensurePipUpgrade ( foundPython : string ) {
206
213
try {
207
- execaSync ( foundPython , [ "-m" , "ensurepip" , "-U" , "--upgrade" ] , { stdio : "inherit" } )
214
+ await execa ( foundPython , [ "-m" , "ensurepip" , "-U" , "--upgrade" ] , { stdio : "inherit" } )
208
215
return true
209
216
} catch ( err1 ) {
210
217
info ( ( err1 as Error ) ?. toString ?.( ) )
211
218
try {
212
219
// ensure pip is disabled on Ubuntu
213
- execaSync ( foundPython , [ "-m" , "pip" , "install" , "--upgrade" , "pip" ] , { stdio : "inherit" } )
220
+ await execa ( foundPython , [ "-m" , "pip" , "install" , "--upgrade" , "pip" ] , { stdio : "inherit" } )
214
221
return true
215
222
} catch ( err2 ) {
216
223
info ( ( err2 as Error ) ?. toString ?.( ) )
@@ -235,11 +242,6 @@ function setupPipSystem() {
235
242
throw new Error ( `Could not install pip on ${ process . platform } ` )
236
243
}
237
244
238
- /** Install wheel (required for Conan, Meson, etc.) */
239
- function setupWheel ( foundPython : string ) {
240
- execaSync ( foundPython , [ "-m" , "pip" , "install" , "-U" , "wheel" ] , { stdio : "inherit" } )
241
- }
242
-
243
245
async function addPythonBaseExecPrefix_raw ( python : string ) {
244
246
const dirs : string [ ] = [ ]
245
247
0 commit comments