fix: fisrt check python binary instead of python3

To avoid preferring brew over system python
This commit is contained in:
Amin Yahyaabadi 2024-09-17 17:17:23 -07:00
parent 381411326c
commit d316735ce5
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
6 changed files with 10 additions and 10 deletions

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

View File

@ -183,7 +183,7 @@ async function setupPythonSystem(setupDir: string, version: 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
const foundPython = await isPythonUpToDate(pythonBin, binDir)
if (foundPython !== undefined) {
@ -215,10 +215,8 @@ async function isPythonUpToDate(candidate: string, binDir?: string) {
try {
if (binDir !== undefined) {
const pythonBinPath = join(binDir, addExeExt(candidate))
if (await pathExists(pythonBinPath)) {
if (await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
return pythonBinPath
}
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
return pythonBinPath
}
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

View File

@ -50,6 +50,7 @@ export async function setupPipPackWithPython(
const { usePipx = true, user = true, upgrade = false, isLibrary = false } = options
const isPipx = usePipx && !isLibrary && (await hasPipx(givenPython))
const pip = isPipx ? "pipx" : "pip"
// 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) {
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_() {