@@ -6,6 +6,9 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
66import { isGitHubCI } from "../utils/env/isci"
77import { warning , info } from "../utils/io/io"
88import { isArch } from "../utils/env/isArch"
9+ import which from "which"
10+ import { InstallationInfo } from "../utils/setup/setupBin"
11+ import { dirname , join } from "path"
912
1013export async function setupPython ( version : string , setupDir : string , arch : string ) {
1114 if ( ! isGitHubCI ( ) ) {
@@ -21,20 +24,28 @@ export async function setupPython(version: string, setupDir: string, arch: strin
2124 }
2225}
2326
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 > {
2633 switch ( process . platform ) {
2734 case "win32" : {
2835 if ( setupDir ) {
2936 await setupChocoPack ( "python3" , version , [ `--params=/InstallDir:${ setupDir } ` ] )
3037 } else {
3138 await setupChocoPack ( "python3" , version )
3239 }
33-
3440 // 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 )
3546 /** 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 }
3849 }
3950 case "darwin" : {
4051 return setupBrewPack ( "python3" , version )
0 commit comments