feat: add execPaths when installing python

This commit is contained in:
Amin Yahyaabadi 2023-06-28 15:16:31 -07:00
parent 6637fda894
commit 08aaab1859
6 changed files with 37 additions and 25 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,8 +18,33 @@ import { isBinUptoDate } from "../utils/setup/version"
import { execaSync } from "execa"
import { unique } from "../utils/std"
import { DefaultVersions } from "../versions/default_versions"
import assert from "assert"
export async function setupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
const installInfo = await findOrSetupPython(version, setupDir, arch)
assert(installInfo.bin !== undefined)
const foundPython = installInfo.bin
// setup pip
const foundPip = await findOrSetupPip(foundPython)
if (foundPip === undefined) {
throw new Error("pip was not installed correctly")
}
// setup wheel
try {
setupWheel(foundPython)
} catch (err) {
warning(`Failed to install wheels: ${(err as Error).toString()}. Ignoring...`)
}
// add python bin paths to PATH
const _execPaths = await addPythonBaseExecPrefix(foundPython)
return installInfo
}
async function findOrSetupPython(version: string, setupDir: string, arch: string) {
let installInfo: InstallationInfo | undefined
let foundPython = await findPython()
@ -53,19 +78,6 @@ export async function setupPython(version: string, setupDir: string, arch: strin
installInfo.bin = foundPython
}
// setup pip
const foundPip = await findOrSetupPip(foundPython)
if (foundPip === undefined) {
throw new Error("pip was not installed correctly")
}
// setup wheel
try {
setupWheel(foundPython)
} catch (err) {
warning(`Failed to install wheels: ${(err as Error).toString()}. Ignoring...`)
}
return installInfo
}

View File

@ -10,7 +10,7 @@ import { getVersion } from "../../versions/versions"
/* eslint-disable require-atomic-updates */
let python: string | undefined
let binDirs: string[] | undefined
let execPaths: string[] | undefined
/** A function that installs a package using pip */
export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> {
@ -24,11 +24,11 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
stdio: "inherit",
})
if (binDirs === undefined) {
binDirs = await addPythonBaseExecPrefix(python)
if (execPaths === undefined) {
execPaths = await addPythonBaseExecPrefix(python)
}
const binDir = await findBinDir(binDirs, name)
const binDir = await findBinDir(execPaths, name)
await addPath(binDir)