Skip to content

Commit

Permalink
fix: fisrt check python binary instead of python3
Browse files Browse the repository at this point in the history
To avoid preferring brew over system python
  • Loading branch information
aminya committed Sep 18, 2024
1 parent 3814113 commit d316735
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_() {
Expand Down

0 comments on commit d316735

Please sign in to comment.