fix: update setup-python to v3.1.2

This commit is contained in:
Amin Yahyaabadi 2022-04-18 18:29:17 -07:00
parent fe36759e27
commit 0f42dc4b13
2 changed files with 36 additions and 26 deletions

View File

@ -42,7 +42,7 @@
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
"semver": "7.3.7",
"setup-python": "github:actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a",
"setup-python": "github:actions/setup-python#v3.1.2",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"untildify": "^4.0.0",
"which": "^2.0.2"

View File

@ -1,43 +1,53 @@
import * as finder from "setup-python/src/find-python"
import * as finderPyPy from "setup-python/src/find-pypy"
import { existsSync } from "fs"
import { warning } from "../utils/io/io"
import { info } from "@actions/core"
import { info, warning } from "../utils/io/io"
import * as core from "@actions/core"
import path from "path"
import { isGitHubCI } from "../utils/env/isci"
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
// import { isGhes } from "setup-python/src/utils"
import { isCacheFeatureAvailable } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy-")
}
// // @ts-ignore
// async function cacheDependencies(cache: string, pythonVersion: string) {
// if (isGhes()) {
// throw new Error("Caching is not supported on GHES")
// }
// const cacheDependencyPath = core.getInput("cache-dependency-path") || undefined
// const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
// await cacheDistributor.restoreCache()
// }
async function cacheDependencies(cache: string, pythonVersion: string) {
const cacheDependencyPath = undefined // core.getInput("cache-dependency-path") || undefined
const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
await cacheDistributor.restoreCache()
}
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
let pythonVersion: string
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
core.debug(`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env.AGENT_TOOLSDIRECTORY}`)
process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
} else {
const installed = await finder.findPythonVersion(version, arch)
pythonVersion = installed.version
info(`Successfully setup ${installed.impl} (${pythonVersion})`)
core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE==${process.env.RUNNER_TOOL_CACHE}`)
}
try {
if (version) {
let pythonVersion: string
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
info(
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
)
} else {
const installed = await finder.useCpythonVersion(version, arch)
pythonVersion = installed.version
info(`Successfully setup ${installed.impl} (${pythonVersion})`)
}
// const cache = core.getInput("cache")
// if (cache) {
// await cacheDependencies(cache, pythonVersion)
// }
const cache = "pip" // core.getInput("cache") // package manager used for caching
if (isCacheFeatureAvailable()) {
await cacheDependencies(cache, pythonVersion)
}
}
} catch (err) {
core.setFailed((err as Error).message)
}
if (isGitHubCI()) {
addPythonLoggingMatcher()