@@ -6,6 +6,9 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
6
6
import { isGitHubCI } from "../utils/env/isci"
7
7
import { warning , info } from "../utils/io/io"
8
8
import { isArch } from "../utils/env/isArch"
9
+ import which from "which"
10
+ import { InstallationInfo } from "../utils/setup/setupBin"
11
+ import { dirname , join } from "path"
9
12
10
13
export async function setupPython ( version : string , setupDir : string , arch : string ) {
11
14
if ( ! isGitHubCI ( ) ) {
@@ -21,20 +24,28 @@ export async function setupPython(version: string, setupDir: string, arch: strin
21
24
}
22
25
}
23
26
24
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- export async function setupPythonViaSystem ( version : string , setupDir : string , _arch : string ) {
27
+ export async function setupPythonViaSystem (
28
+ version : string ,
29
+ setupDir : string ,
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ _arch : string
32
+ ) : Promise < InstallationInfo > {
26
33
switch ( process . platform ) {
27
34
case "win32" : {
28
35
if ( setupDir ) {
29
36
await setupChocoPack ( "python3" , version , [ `--params=/InstallDir:${ setupDir } ` ] )
30
37
} else {
31
38
await setupChocoPack ( "python3" , version )
32
39
}
33
-
34
40
// Adding the bin dir to the path
41
+ const pythonBinPath =
42
+ which . sync ( "python3.exe" , { nothrow : true } ) ??
43
+ which . sync ( "python.exe" , { nothrow : true } ) ??
44
+ join ( setupDir , "python.exe" )
45
+ const pythonSetupDir = dirname ( pythonBinPath )
35
46
/** The directory which the tool is installed to */
36
- await activateWinPython ( setupDir )
37
- return { installDir : setupDir , binDir : setupDir }
47
+ await activateWinPython ( pythonSetupDir )
48
+ return { installDir : pythonSetupDir , binDir : pythonSetupDir }
38
49
}
39
50
case "darwin" : {
40
51
return setupBrewPack ( "python3" , version )
0 commit comments