Merge pull request #97 from aminya/python [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-07-05 21:15:07 -07:00 committed by GitHub
commit 2c84fbf623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 54 additions and 49 deletions

2
dist/actions_python.239cf807.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/actions_python.239cf807.js.map 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

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

@ -49,7 +49,7 @@
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
"semver": "7.3.7",
"setup-python": "github:actions/setup-python#ffcd00020c213885323d35524aa155f17870b8dd",
"setup-python": "github:actions/setup-python#f0bcf8be037eba11327da6eaf40cd99a2a092494",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ubuntu-version": "^2.0.0",
"untildify": "^4.0.0",

View File

@ -38,7 +38,7 @@ specifiers:
prettier: 2.7.1
prettier-config-atomic: ^3.0.10
semver: 7.3.7
setup-python: github:actions/setup-python#ffcd00020c213885323d35524aa155f17870b8dd
setup-python: github:actions/setup-python#f0bcf8be037eba11327da6eaf40cd99a2a092494
shx: 0.3.4
terser-config-atomic: ^0.1.1
time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e
@ -59,7 +59,7 @@ dependencies:
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
numerous: 1.0.3
semver: 7.3.7
setup-python: github.com/actions/setup-python/ffcd00020c213885323d35524aa155f17870b8dd
setup-python: github.com/actions/setup-python/f0bcf8be037eba11327da6eaf40cd99a2a092494
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
ubuntu-version: 2.0.0
untildify: 4.0.0
@ -92,8 +92,8 @@ devDependencies:
packages:
/@actions/cache/2.0.6:
resolution: {integrity: sha512-Z39ZrWaTRRPaV/AOQdY7hve+Iy/HloH5prpz+k+0lZgGQs/3SeO0UYSIakVuXOk2pdMZnl0Nv0PoK1rmh9YfGQ==}
/@actions/cache/3.0.0:
resolution: {integrity: sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==}
dependencies:
'@actions/core': 1.9.0
'@actions/exec': 1.1.1
@ -8192,12 +8192,12 @@ packages:
readable-stream: 3.6.0
dev: true
github.com/actions/setup-python/ffcd00020c213885323d35524aa155f17870b8dd:
resolution: {tarball: https://codeload.github.com/actions/setup-python/tar.gz/ffcd00020c213885323d35524aa155f17870b8dd}
github.com/actions/setup-python/f0bcf8be037eba11327da6eaf40cd99a2a092494:
resolution: {tarball: https://codeload.github.com/actions/setup-python/tar.gz/f0bcf8be037eba11327da6eaf40cd99a2a092494}
name: setup-python
version: 4.0.0
dependencies:
'@actions/cache': 2.0.6
'@actions/cache': 3.0.0
'@actions/core': 1.9.0
'@actions/exec': 1.1.1
'@actions/glob': 0.2.1

View File

@ -1,10 +0,0 @@
import { isCacheFeatureAvailable } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
export async function cacheDependencies(cache: string, pythonVersion: string) {
if (isCacheFeatureAvailable()) {
const cacheDependencyPath = undefined // core.getInput("cache-dependency-path") || undefined
const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
await cacheDistributor.restoreCache()
}
}

View File

@ -5,56 +5,71 @@ import { info, warning } from "../utils/io/io"
import { debug } from "@actions/core"
import path from "path"
import { isGitHubCI } from "../utils/env/isci"
import { cacheDependencies } from "./actions_cache"
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy")
}
// function resolveVersionInput(version: string): string {
// let versionFile = getInput("python-version-file")
/*
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 && versionFile) {
warning("Both python-version and python-version-file inputs are specified, only python-version will be used")
}
// if (version) {
// return version
// }
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}`)
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
// }
return version
}
*/
export 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) {
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
debug(`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env.AGENT_TOOLSDIRECTORY}`)
// According to the README windows binaries do not require to be installed
// 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.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
} else {
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE==${process.env.RUNNER_TOOL_CACHE}`)
}
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env.RUNNER_TOOL_CACHE}`)
// const version = resolveVersionInput(versionGiven)
if (version) {
let pythonVersion: string
if (isPyPyVersion(version)) {
const installed = await findPyPyVersion(version, arch)
const installed = await findPyPyVersion(version, arch, true)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
} else {
const installed = await useCpythonVersion(version, arch)
const installed = await useCpythonVersion(version, arch, true)
pythonVersion = installed.version
info(`Successfully set up ${installed.impl} (${pythonVersion})`)
}
const cache = "pip" // core.getInput("cache") // package manager used for caching
await cacheDependencies(cache, pythonVersion)
if (isCacheFeatureAvailable()) {
const cache = "pip" // core.getInput("cache") // package manager used for caching
await cacheDependencies(cache, pythonVersion)
}
}
if (isGitHubCI()) {