mirror of https://github.com/aminya/setup-cpp
fix: memoize addPythonBaseExecPrefix
This commit is contained in:
parent
08aaab1859
commit
f6ebfc1d77
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
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
|
@ -98,6 +98,7 @@
|
|||
"gen-readme": "^1.6.0",
|
||||
"is-url-online": "^1.5.0",
|
||||
"jest": "^29.5.0",
|
||||
"micro-memoize": "^4.1.2",
|
||||
"mri": "^1.2.0",
|
||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
||||
"npm-check-updates": "^16.10.13",
|
||||
|
|
|
@ -113,6 +113,9 @@ importers:
|
|||
jest:
|
||||
specifier: ^29.5.0
|
||||
version: 29.5.0(@types/node@20.3.2)(ts-node@10.9.1)
|
||||
micro-memoize:
|
||||
specifier: ^4.1.2
|
||||
version: 4.1.2
|
||||
mri:
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0
|
||||
|
@ -7711,6 +7714,10 @@ packages:
|
|||
engines: {node: '>= 8'}
|
||||
dev: true
|
||||
|
||||
/micro-memoize@4.1.2:
|
||||
resolution: {integrity: sha512-+HzcV2H+rbSJzApgkj0NdTakkC+bnyeiUxgT6/m7mjcz1CmM22KYFKp+EVj1sWe4UYcnriJr5uqHQD/gMHLD+g==}
|
||||
dev: true
|
||||
|
||||
/micromark-core-commonmark@1.1.0:
|
||||
resolution: {integrity: sha512-BgHO1aRbolh2hcrzL2d1La37V0Aoz73ymF8rAcKnohLy93titmv62E0gP8Hrx9PKcKrqCZ1BbLGbP3bEhoXYlw==}
|
||||
dependencies:
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { getExecOutput } from "@actions/exec"
|
||||
import assert from "assert"
|
||||
import { GITHUB_ACTIONS } from "ci-info"
|
||||
import { info, warning } from "ci-log"
|
||||
import { execaSync } from "execa"
|
||||
import memoize from "micro-memoize"
|
||||
import { dirname, join } from "patha"
|
||||
import which from "which"
|
||||
import { addPath } from "../utils/env/addEnv"
|
||||
import { hasDnf } from "../utils/env/hasDnf"
|
||||
import { isArch } from "../utils/env/isArch"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||
import { setupBrewPack } from "../utils/setup/setupBrewPack"
|
||||
import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||
import { GITHUB_ACTIONS } from "ci-info"
|
||||
import { warning, info } from "ci-log"
|
||||
import { isArch } from "../utils/env/isArch"
|
||||
import which from "which"
|
||||
import { InstallationInfo } from "../utils/setup/setupBin"
|
||||
import { dirname, join } from "patha"
|
||||
import { hasDnf } from "../utils/env/hasDnf"
|
||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
import { getExecOutput } from "@actions/exec"
|
||||
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
|
||||
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)
|
||||
|
@ -204,7 +205,7 @@ function setupWheel(foundPython: string) {
|
|||
execaSync(foundPython, ["-m", "pip", "install", "-U", "wheel"], { stdio: "inherit" })
|
||||
}
|
||||
|
||||
export async function addPythonBaseExecPrefix(python: string) {
|
||||
async function addPythonBaseExecPrefix_raw(python: string) {
|
||||
const dirs: string[] = []
|
||||
|
||||
// detection based on the platform
|
||||
|
@ -222,3 +223,10 @@ export async function addPythonBaseExecPrefix(python: string) {
|
|||
// remove duplicates
|
||||
return unique(dirs)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the base exec prefix to the PATH. This is required for Conan, Meson, etc. to work properly.
|
||||
*
|
||||
* The answer is cached for subsequent calls
|
||||
*/
|
||||
export const addPythonBaseExecPrefix = memoize(addPythonBaseExecPrefix_raw)
|
||||
|
|
|
@ -10,7 +10,6 @@ import { getVersion } from "../../versions/versions"
|
|||
|
||||
/* eslint-disable require-atomic-updates */
|
||||
let python: 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,10 +23,7 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
|||
stdio: "inherit",
|
||||
})
|
||||
|
||||
if (execPaths === undefined) {
|
||||
execPaths = await addPythonBaseExecPrefix(python)
|
||||
}
|
||||
|
||||
const execPaths = await addPythonBaseExecPrefix(python)
|
||||
const binDir = await findBinDir(execPaths, name)
|
||||
|
||||
await addPath(binDir)
|
||||
|
|
Loading…
Reference in New Issue