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