fix: update setup-python

This commit is contained in:
Amin Yahyaabadi 2022-10-19 14:37:02 -07:00
parent 453df99f1c
commit 9d1119edc9
9 changed files with 1146 additions and 1070 deletions

File diff suppressed because one or more lines are too long

2
dist/actions_python.815c8aab.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -65,8 +65,8 @@
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1", "msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3", "numerous": "1.0.3",
"patha": "^0.4.1", "patha": "^0.4.1",
"setup-python": "github:actions/setup-python#c474c82340438924daab9282d07300bfe7e3692d",
"semver": "7.3.8", "semver": "7.3.8",
"setup-python": "github:actions/setup-python#v4.3.0",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e", "time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ubuntu-version": "^2.0.0", "ubuntu-version": "^2.0.0",
"untildify-user": "workspace:1.0.0", "untildify-user": "workspace:1.0.0",

File diff suppressed because it is too large Load Diff

View File

@ -5,69 +5,47 @@ import { info, warning } from "ci-log"
import { debug } from "@actions/core" import { debug } from "@actions/core"
import { join } from "patha" import { join } from "patha"
import ciDetect from "@npmcli/ci-detect" import ciDetect from "@npmcli/ci-detect"
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils" import { isCacheFeatureAvailable, IS_MAC } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory" import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
function isPyPyVersion(versionSpec: string) { function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy") return versionSpec.startsWith("pypy")
} }
/*
function resolveVersionInput(version: string): string {
let versionFile = getInput("python-version-file")
if (version && versionFile) {
warning("Both python-version and python-version-file inputs are specified, only python-version will be used")
}
if (version) {
return version
}
versionFile = versionFile || ".python-version"
if (!existsSync(versionFile)) {
throw new Error(`The specified python version file at: ${versionFile} does not exist`)
}
version = readFileSync(versionFile, "utf8")
info(`Resolved ${versionFile} as ${version}`)
return version
}
*/
export async function cacheDependencies(cache: string, pythonVersion: string) { export async function cacheDependencies(cache: string, pythonVersion: string) {
const cacheDependencyPath = undefined // core.getInput("cache-dependency-path") || undefined const cacheDependencyPath = undefined
const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath) const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
await cacheDistributor.restoreCache() await cacheDistributor.restoreCache()
} }
const checkLatest = false
export async function setupActionsPython(version: string, _setupDir: string, arch: string) { export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
// According to the README windows binaries do not require to be installed if (IS_MAC) {
// in the specific location, but Mac and Linux do
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) {
if (IS_LINUX) {
process.env.AGENT_TOOLSDIRECTORY = "/opt/hostedtoolcache"
} else {
process.env.AGENT_TOOLSDIRECTORY = "/Users/runner/hostedtoolcache" process.env.AGENT_TOOLSDIRECTORY = "/Users/runner/hostedtoolcache"
} }
const agent_toolsdirectory = process.env.AGENT_TOOLSDIRECTORY?.trim()
if (typeof agent_toolsdirectory === "string" && agent_toolsdirectory !== "") {
process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
} }
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env.RUNNER_TOOL_CACHE}`)
// const version = resolveVersionInput(versionGiven) debug(`Python is expected to be installed into ${process.env.RUNNER_TOOL_CACHE}`)
if (version) { if (version) {
let pythonVersion: string let pythonVersion: string
if (isPyPyVersion(version)) { if (isPyPyVersion(version)) {
const installed = await findPyPyVersion(version, arch, true) const installed = await findPyPyVersion(version, arch, true, checkLatest)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}` pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`) info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
} else { } else {
const installed = await useCpythonVersion(version, arch, true) const installed = await useCpythonVersion(version, arch, true, checkLatest)
pythonVersion = installed.version pythonVersion = installed.version
info(`Successfully set up ${installed.impl} (${pythonVersion})`) info(`Successfully set up ${installed.impl} (${pythonVersion})`)
} }
if (isCacheFeatureAvailable()) { if (isCacheFeatureAvailable()) {
const cache = "pip" // core.getInput("cache") // package manager used for caching const cache = "pip" // package manager used for caching
await cacheDependencies(cache, pythonVersion) await cacheDependencies(cache, pythonVersion)
} }
} }

View File

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"strict": true, "strict": true,
"strictNullChecks": true, "strictNullChecks": true,
"noUnusedLocals": true, "noUnusedLocals": false,
"noUnusedParameters": true, "noUnusedParameters": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"noImplicitAny": true, "noImplicitAny": true,