Skip to content

Commit d316735

Browse files
committed
fix: fisrt check python binary instead of python3
To avoid preferring brew over system python
1 parent 3814113 commit d316735

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/python/python.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async function setupPythonSystem(setupDir: string, version: string) {
183183
}
184184

185185
async function findPython(binDir?: string) {
186-
for (const pythonBin of ["python3", "python"]) {
186+
for (const pythonBin of ["python", "python3"]) {
187187
// eslint-disable-next-line no-await-in-loop
188188
const foundPython = await isPythonUpToDate(pythonBin, binDir)
189189
if (foundPython !== undefined) {
@@ -215,10 +215,8 @@ async function isPythonUpToDate(candidate: string, binDir?: string) {
215215
try {
216216
if (binDir !== undefined) {
217217
const pythonBinPath = join(binDir, addExeExt(candidate))
218-
if (await pathExists(pythonBinPath)) {
219-
if (await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
220-
return pythonBinPath
221-
}
218+
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
219+
return pythonBinPath
222220
}
223221
}
224222
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

src/utils/setup/setupPipPack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export async function setupPipPackWithPython(
5050
const { usePipx = true, user = true, upgrade = false, isLibrary = false } = options
5151

5252
const isPipx = usePipx && !isLibrary && (await hasPipx(givenPython))
53+
5354
const pip = isPipx ? "pipx" : "pip"
5455

5556
// 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) {
104105
}
105106

106107
export async function hasPipx(givenPython: string) {
107-
return (await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })).exitCode === 0
108+
const res = await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })
109+
return res.exitCode === 0
108110
}
109111

110112
async function getPipxHome_() {

0 commit comments

Comments
 (0)