setup-cpp/src/python/actions_python.ts

47 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-09-20 20:24:17 +08:00
import * as core from "@actions/core"
import * as finder from "setup-python/src/find-python"
import * as finderPyPy from "setup-python/src/find-pypy"
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
// import { isGhes } from "setup-python/src/utils"
2021-09-20 20:24:17 +08:00
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()
// }
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
let pythonVersion: string
2021-09-20 20:24:17 +08:00
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
2021-09-20 20:24:17 +08:00
core.info(
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
)
} else {
const installed = await finder.findPythonVersion(version, arch)
pythonVersion = installed.version
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
2021-09-20 20:24:17 +08:00
}
// const cache = core.getInput("cache")
// if (cache) {
// await cacheDependencies(cache, pythonVersion)
// }
2021-11-22 06:45:35 +08:00
// fails
// const matchersPath = path.join(__dirname, '../..', '.github');
// core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
2021-11-22 06:45:35 +08:00
// core.info(`##[add-matcher]${path.join("./.github", "python.json")}`)
2021-09-20 20:24:17 +08:00
return undefined
}