Skip to content

Commit ff997f2

Browse files
committed
fix: ensure running setup-python in github actions
1 parent 488c981 commit ff997f2

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

dist/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/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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
66
import { isGitHubCI } from "../utils/env/isci"
77

88
export function setupPython(version: string, setupDir: string, arch: string) {
9-
if (!isGitHubCI() || process.platform === "win32") {
9+
if (!isGitHubCI()) {
1010
// TODO parse version
1111
return setupPythonViaSystem(version, setupDir, arch)
1212
}
@@ -23,7 +23,12 @@ export function setupPython(version: string, setupDir: string, arch: string) {
2323
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
2424
switch (process.platform) {
2525
case "win32": {
26-
setupChocoPack("python3", version, setupDir ? [`--params=/InstallDir:${setupDir}`] : [])
26+
if (setupDir) {
27+
setupChocoPack("python3", version, [`--params=/InstallDir:${setupDir}`])
28+
} else {
29+
setupChocoPack("python3", version)
30+
}
31+
2732
// Adding the bin dir to the path
2833
/** The directory which the tool is installed to */
2934
activateWinPython(setupDir)

src/utils/setup/setupPipPack.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,28 @@ import { addPath } from "../path/addPath"
77
import { setupPython } from "../../python/python"
88
import { isBinUptoDate } from "./version"
99
import { join } from "path"
10+
import { isGitHubCI } from "../env/isci"
1011
import { getVersion } from "../../default_versions"
11-
import { untildify_user as untildify } from "../path/untildify"
1212

1313
let pip: string | undefined
14-
let python: string = "python3"
1514

1615
let binDir: string | undefined
1716

1817
/** A function that installs a package using pip */
1918
export async function setupPipPack(name: string, version?: string) {
2019
// setup python and pip if needed
2120
if (pip === undefined) {
22-
if (process.platform === "win32") {
23-
const installationInfo = await setupPython(getVersion("python", undefined), untildify("python"), process.arch)
24-
if (installationInfo?.installDir !== undefined) {
25-
pip = join(installationInfo.installDir, "Scripts", "pip3.exe")
26-
python = join(installationInfo.installDir, "python.exe")
27-
} else {
28-
pip = "pip3"
29-
}
21+
if (isGitHubCI() && process.platform === "win32") {
22+
// run setupPython in actions_python anyways
23+
await setupPython(getVersion("python", undefined), "", process.arch)
24+
}
25+
if (which.sync("pip3", { nothrow: true }) !== null) {
26+
pip = "pip3"
27+
} else if (which.sync("pip", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
28+
pip = "pip"
3029
} else {
31-
if (which.sync("pip3", { nothrow: true }) !== null) {
32-
pip = "pip3"
33-
} else if (which.sync("pip", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
34-
pip = "pip"
35-
} else {
36-
await setupPython("3.x", "", process.arch)
37-
pip = "pip3"
38-
}
30+
await setupPython("3.x", "", process.arch)
31+
pip = "pip3"
3932
}
4033
}
4134

@@ -52,7 +45,7 @@ export async function setupPipPack(name: string, version?: string) {
5245
// windows or others
5346
try {
5447
binDir = join(
55-
(await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
48+
(await getExecOutput(`python3 -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
5649
"Scripts"
5750
)
5851
} catch {

0 commit comments

Comments
 (0)