Skip to content

Commit 08aaab1

Browse files
committed
feat: add execPaths when installing python
1 parent 6637fda commit 08aaab1

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

dist/node12/setup-cpp.js

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

dist/node12/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/node16/setup-cpp.js

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

dist/node16/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: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,33 @@ import { isBinUptoDate } from "../utils/setup/version"
1818
import { execaSync } from "execa"
1919
import { unique } from "../utils/std"
2020
import { DefaultVersions } from "../versions/default_versions"
21+
import assert from "assert"
2122

2223
export async function setupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
24+
const installInfo = await findOrSetupPython(version, setupDir, arch)
25+
assert(installInfo.bin !== undefined)
26+
const foundPython = installInfo.bin
27+
28+
// setup pip
29+
const foundPip = await findOrSetupPip(foundPython)
30+
if (foundPip === undefined) {
31+
throw new Error("pip was not installed correctly")
32+
}
33+
34+
// setup wheel
35+
try {
36+
setupWheel(foundPython)
37+
} catch (err) {
38+
warning(`Failed to install wheels: ${(err as Error).toString()}. Ignoring...`)
39+
}
40+
41+
// add python bin paths to PATH
42+
const _execPaths = await addPythonBaseExecPrefix(foundPython)
43+
44+
return installInfo
45+
}
46+
47+
async function findOrSetupPython(version: string, setupDir: string, arch: string) {
2348
let installInfo: InstallationInfo | undefined
2449
let foundPython = await findPython()
2550

@@ -53,19 +78,6 @@ export async function setupPython(version: string, setupDir: string, arch: strin
5378
installInfo.bin = foundPython
5479
}
5580

56-
// setup pip
57-
const foundPip = await findOrSetupPip(foundPython)
58-
if (foundPip === undefined) {
59-
throw new Error("pip was not installed correctly")
60-
}
61-
62-
// setup wheel
63-
try {
64-
setupWheel(foundPython)
65-
} catch (err) {
66-
warning(`Failed to install wheels: ${(err as Error).toString()}. Ignoring...`)
67-
}
68-
6981
return installInfo
7082
}
7183

src/utils/setup/setupPipPack.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getVersion } from "../../versions/versions"
1010

1111
/* eslint-disable require-atomic-updates */
1212
let python: string | undefined
13-
let binDirs: string[] | undefined
13+
let execPaths: string[] | undefined
1414

1515
/** A function that installs a package using pip */
1616
export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> {
@@ -24,11 +24,11 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
2424
stdio: "inherit",
2525
})
2626

27-
if (binDirs === undefined) {
28-
binDirs = await addPythonBaseExecPrefix(python)
27+
if (execPaths === undefined) {
28+
execPaths = await addPythonBaseExecPrefix(python)
2929
}
3030

31-
const binDir = await findBinDir(binDirs, name)
31+
const binDir = await findBinDir(execPaths, name)
3232

3333
await addPath(binDir)
3434

0 commit comments

Comments
 (0)