mirror of https://github.com/aminya/setup-cpp
fix: fisrt check python binary instead of python3
To avoid preferring brew over system python
This commit is contained in:
parent
381411326c
commit
d316735ce5
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -183,7 +183,7 @@ async function setupPythonSystem(setupDir: string, version: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findPython(binDir?: string) {
|
async function findPython(binDir?: string) {
|
||||||
for (const pythonBin of ["python3", "python"]) {
|
for (const pythonBin of ["python", "python3"]) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const foundPython = await isPythonUpToDate(pythonBin, binDir)
|
const foundPython = await isPythonUpToDate(pythonBin, binDir)
|
||||||
if (foundPython !== undefined) {
|
if (foundPython !== undefined) {
|
||||||
|
@ -215,12 +215,10 @@ async function isPythonUpToDate(candidate: string, binDir?: string) {
|
||||||
try {
|
try {
|
||||||
if (binDir !== undefined) {
|
if (binDir !== undefined) {
|
||||||
const pythonBinPath = join(binDir, addExeExt(candidate))
|
const pythonBinPath = join(binDir, addExeExt(candidate))
|
||||||
if (await pathExists(pythonBinPath)) {
|
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
|
||||||
if (await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
|
|
||||||
return pythonBinPath
|
return pythonBinPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
const pythonBinPaths = (await which(candidate, { nothrow: true, all: true })) ?? []
|
const pythonBinPaths = (await which(candidate, { nothrow: true, all: true })) ?? []
|
||||||
for (const pythonBinPath of pythonBinPaths) {
|
for (const pythonBinPath of pythonBinPaths) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ export async function setupPipPackWithPython(
|
||||||
const { usePipx = true, user = true, upgrade = false, isLibrary = false } = options
|
const { usePipx = true, user = true, upgrade = false, isLibrary = false } = options
|
||||||
|
|
||||||
const isPipx = usePipx && !isLibrary && (await hasPipx(givenPython))
|
const isPipx = usePipx && !isLibrary && (await hasPipx(givenPython))
|
||||||
|
|
||||||
const pip = isPipx ? "pipx" : "pip"
|
const pip = isPipx ? "pipx" : "pip"
|
||||||
|
|
||||||
// if upgrade is not requested, check if the package is already installed, and return if it is
|
// if upgrade is not requested, check if the package is already installed, and return if it is
|
||||||
|
@ -104,7 +105,8 @@ async function finishPipPackageInstall(givenPython: string, name: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function hasPipx(givenPython: string) {
|
export async function hasPipx(givenPython: string) {
|
||||||
return (await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })).exitCode === 0
|
const res = await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })
|
||||||
|
return res.exitCode === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPipxHome_() {
|
async function getPipxHome_() {
|
||||||
|
|
Loading…
Reference in New Issue