mirror of https://github.com/aminya/setup-cpp
fix: find the path of python on windows using which
This commit is contained in:
parent
043050f031
commit
1e2c406cc3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -6,6 +6,9 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { isGitHubCI } from "../utils/env/isci"
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
import { warning, info } from "../utils/io/io"
|
import { warning, info } from "../utils/io/io"
|
||||||
import { isArch } from "../utils/env/isArch"
|
import { isArch } from "../utils/env/isArch"
|
||||||
|
import which from "which"
|
||||||
|
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||||
|
import { dirname, join } from "path"
|
||||||
|
|
||||||
export async function setupPython(version: string, setupDir: string, arch: string) {
|
export async function setupPython(version: string, setupDir: string, arch: string) {
|
||||||
if (!isGitHubCI()) {
|
if (!isGitHubCI()) {
|
||||||
|
@ -21,8 +24,12 @@ export async function setupPython(version: string, setupDir: string, arch: strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
export async function setupPythonViaSystem(
|
||||||
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
|
version: string,
|
||||||
|
setupDir: string,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_arch: string
|
||||||
|
): Promise<InstallationInfo> {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
if (setupDir) {
|
if (setupDir) {
|
||||||
|
@ -30,11 +37,15 @@ export async function setupPythonViaSystem(version: string, setupDir: string, _a
|
||||||
} else {
|
} else {
|
||||||
await setupChocoPack("python3", version)
|
await setupChocoPack("python3", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding the bin dir to the path
|
// Adding the bin dir to the path
|
||||||
|
const pythonBinPath =
|
||||||
|
which.sync("python3.exe", { nothrow: true }) ??
|
||||||
|
which.sync("python.exe", { nothrow: true }) ??
|
||||||
|
join(setupDir, "python.exe")
|
||||||
|
const pythonSetupDir = dirname(pythonBinPath)
|
||||||
/** The directory which the tool is installed to */
|
/** The directory which the tool is installed to */
|
||||||
await activateWinPython(setupDir)
|
await activateWinPython(pythonSetupDir)
|
||||||
return { installDir: setupDir, binDir: setupDir }
|
return { installDir: pythonSetupDir, binDir: pythonSetupDir }
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
return setupBrewPack("python3", version)
|
return setupBrewPack("python3", version)
|
||||||
|
|
Loading…
Reference in New Issue