Skip to content

Commit c75a134

Browse files
committed
fix: add default search paths for python on Windows
1 parent 45a40e9 commit c75a134

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

dist/actions/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions/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/legacy/setup-cpp.js

Lines changed: 2 additions & 2 deletions
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.

src/python/python.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import assert from "assert"
2-
/* eslint-disable require-atomic-updates */
2+
import { homedir } from "os"
3+
import { parse as pathParse } from "path"
34
import { getExecOutput } from "@actions/exec"
45
import { GITHUB_ACTIONS } from "ci-info"
56
import { info, warning } from "ci-log"
67
import { execa } from "execa"
8+
import { readdir } from "fs/promises"
79
import memoize from "micro-memoize"
810
import { pathExists } from "path-exists"
911
import { addExeExt, dirname, join } from "patha"
@@ -175,6 +177,24 @@ async function findPython(binDir?: string) {
175177
return foundPython
176178
}
177179
}
180+
181+
// On Windows, search in C:\PythonXX
182+
if (process.platform === "win32") {
183+
const rootDir = pathParse(homedir()).root
184+
// find all directories in rootDir using readdir
185+
const pythonDirs = (await readdir(rootDir)).filter((dir) => dir.startsWith("Python"))
186+
187+
for (const pythonDir of pythonDirs) {
188+
for (const pythonBin of ["python3", "python"]) {
189+
// eslint-disable-next-line no-await-in-loop
190+
const foundPython = await isPythonUpToDate(pythonBin, join(rootDir, pythonDir))
191+
if (foundPython !== undefined) {
192+
return foundPython
193+
}
194+
}
195+
}
196+
}
197+
178198
return undefined
179199
}
180200

0 commit comments

Comments
 (0)