mirror of https://github.com/aminya/setup-cpp
fix: manually memoize getPython
This commit is contained in:
parent
99db11072d
commit
3a8e462ed6
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
|
@ -26,7 +26,11 @@ import { isBinUptoDate } from "../utils/setup/version.js"
|
|||
import { unique } from "../utils/std/index.js"
|
||||
import { MinVersions } from "../versions/default_versions.js"
|
||||
|
||||
export async function setupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||
export async function setupPython(
|
||||
version: string,
|
||||
setupDir: string,
|
||||
arch: string,
|
||||
): Promise<InstallationInfo & { bin: string }> {
|
||||
const installInfo = await findOrSetupPython(version, setupDir, arch)
|
||||
assert(installInfo.bin !== undefined)
|
||||
const foundPython = installInfo.bin
|
||||
|
@ -41,7 +45,7 @@ export async function setupPython(version: string, setupDir: string, arch: strin
|
|||
|
||||
await setupWheel(foundPython)
|
||||
|
||||
return installInfo
|
||||
return installInfo as InstallationInfo & { bin: string }
|
||||
}
|
||||
|
||||
async function setupPipx(foundPython: string) {
|
||||
|
|
|
@ -154,14 +154,17 @@ async function getPipxBinDir_() {
|
|||
}
|
||||
const getPipxBinDir = memoize(getPipxBinDir_, { promise: true })
|
||||
|
||||
async function getPython_(): Promise<string> {
|
||||
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
|
||||
if (pythonBin === undefined) {
|
||||
throw new Error("Python binary was not found")
|
||||
/* eslint-disable require-atomic-updates */
|
||||
let pythonBin: string | undefined
|
||||
|
||||
async function getPython(): Promise<string> {
|
||||
if (pythonBin !== undefined) {
|
||||
return pythonBin
|
||||
}
|
||||
|
||||
pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
|
||||
return pythonBin
|
||||
}
|
||||
const getPython = memoize(getPython_, { promise: true })
|
||||
|
||||
type PipxShowType = {
|
||||
venvs: Record<string, {
|
||||
|
|
Loading…
Reference in New Issue