Skip to content

Commit f6ebfc1

Browse files
committed
fix: memoize addPythonBaseExecPrefix
1 parent 08aaab1 commit f6ebfc1

File tree

11 files changed

+77
-65
lines changed

11 files changed

+77
-65
lines changed

dist/node12/actions_python.35d9bb6f.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

dist/node12/actions_python.eaf38279.js

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

dist/node12/actions_python.35d9bb6f.js.map renamed to dist/node12/actions_python.eaf38279.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/node12/setup-cpp.js

Lines changed: 19 additions & 19 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: 19 additions & 19 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.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"gen-readme": "^1.6.0",
9999
"is-url-online": "^1.5.0",
100100
"jest": "^29.5.0",
101+
"micro-memoize": "^4.1.2",
101102
"mri": "^1.2.0",
102103
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
103104
"npm-check-updates": "^16.10.13",

pnpm-lock.yaml

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

src/python/python.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
/* eslint-disable require-atomic-updates */
2+
import { getExecOutput } from "@actions/exec"
3+
import assert from "assert"
4+
import { GITHUB_ACTIONS } from "ci-info"
5+
import { info, warning } from "ci-log"
6+
import { execaSync } from "execa"
7+
import memoize from "micro-memoize"
8+
import { dirname, join } from "patha"
9+
import which from "which"
210
import { addPath } from "../utils/env/addEnv"
11+
import { hasDnf } from "../utils/env/hasDnf"
12+
import { isArch } from "../utils/env/isArch"
13+
import { isUbuntu } from "../utils/env/isUbuntu"
314
import { setupAptPack } from "../utils/setup/setupAptPack"
4-
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
15+
import { InstallationInfo } from "../utils/setup/setupBin"
516
import { setupBrewPack } from "../utils/setup/setupBrewPack"
617
import { setupChocoPack } from "../utils/setup/setupChocoPack"
7-
import { GITHUB_ACTIONS } from "ci-info"
8-
import { warning, info } from "ci-log"
9-
import { isArch } from "../utils/env/isArch"
10-
import which from "which"
11-
import { InstallationInfo } from "../utils/setup/setupBin"
12-
import { dirname, join } from "patha"
13-
import { hasDnf } from "../utils/env/hasDnf"
1418
import { setupDnfPack } from "../utils/setup/setupDnfPack"
15-
import { isUbuntu } from "../utils/env/isUbuntu"
16-
import { getExecOutput } from "@actions/exec"
19+
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
1720
import { isBinUptoDate } from "../utils/setup/version"
18-
import { execaSync } from "execa"
1921
import { unique } from "../utils/std"
2022
import { DefaultVersions } from "../versions/default_versions"
21-
import assert from "assert"
2223

2324
export async function setupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
2425
const installInfo = await findOrSetupPython(version, setupDir, arch)
@@ -204,7 +205,7 @@ function setupWheel(foundPython: string) {
204205
execaSync(foundPython, ["-m", "pip", "install", "-U", "wheel"], { stdio: "inherit" })
205206
}
206207

207-
export async function addPythonBaseExecPrefix(python: string) {
208+
async function addPythonBaseExecPrefix_raw(python: string) {
208209
const dirs: string[] = []
209210

210211
// detection based on the platform
@@ -222,3 +223,10 @@ export async function addPythonBaseExecPrefix(python: string) {
222223
// remove duplicates
223224
return unique(dirs)
224225
}
226+
227+
/**
228+
* Add the base exec prefix to the PATH. This is required for Conan, Meson, etc. to work properly.
229+
*
230+
* The answer is cached for subsequent calls
231+
*/
232+
export const addPythonBaseExecPrefix = memoize(addPythonBaseExecPrefix_raw)

0 commit comments

Comments
 (0)