2021-09-20 20:24:17 +08:00
|
|
|
import * as core from "@actions/core"
|
2021-12-05 22:16:28 +08:00
|
|
|
import * as finder from "setup-python/src/find-python"
|
|
|
|
|
import * as finderPyPy from "setup-python/src/find-pypy"
|
2022-02-05 03:43:56 +08:00
|
|
|
// 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-")
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 03:43:56 +08:00
|
|
|
// // @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()
|
|
|
|
|
// }
|
|
|
|
|
|
2021-11-22 02:46:34 +08:00
|
|
|
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
|
2022-02-05 03:43:56 +08:00
|
|
|
let pythonVersion: string
|
2021-09-20 20:24:17 +08:00
|
|
|
if (isPyPyVersion(version)) {
|
|
|
|
|
const installed = await finderPyPy.findPyPyVersion(version, arch)
|
2022-02-05 03:43:56 +08:00
|
|
|
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)
|
2022-02-05 03:43:56 +08:00
|
|
|
pythonVersion = installed.version
|
|
|
|
|
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
|
2021-09-20 20:24:17 +08:00
|
|
|
}
|
2022-02-05 03:43:56 +08:00
|
|
|
|
|
|
|
|
// const cache = core.getInput("cache")
|
|
|
|
|
// if (cache) {
|
|
|
|
|
// await cacheDependencies(cache, pythonVersion)
|
|
|
|
|
// }
|
|
|
|
|
|
2021-11-22 06:45:35 +08:00
|
|
|
// fails
|
2022-02-05 03:43:56 +08:00
|
|
|
// 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")}`)
|
2022-02-05 03:43:56 +08:00
|
|
|
|
2021-09-20 20:24:17 +08:00
|
|
|
return undefined
|
|
|
|
|
}
|