Skip to content

Commit 2c84fbf

Browse files
authored
Merge pull request #97 from aminya/python [skip ci]
2 parents 6662184 + ed9b316 commit 2c84fbf

10 files changed

+54
-49
lines changed

dist/actions_python.239cf807.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions_python.239cf807.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions_python.678f52ec.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/actions_python.678f52ec.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
5050
"numerous": "1.0.3",
5151
"semver": "7.3.7",
52-
"setup-python": "github:actions/setup-python#ffcd00020c213885323d35524aa155f17870b8dd",
52+
"setup-python": "github:actions/setup-python#f0bcf8be037eba11327da6eaf40cd99a2a092494",
5353
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
5454
"ubuntu-version": "^2.0.0",
5555
"untildify": "^4.0.0",

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/python/actions_cache.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/python/actions_python.ts

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,71 @@ import { info, warning } from "../utils/io/io"
55
import { debug } from "@actions/core"
66
import path from "path"
77
import { isGitHubCI } from "../utils/env/isci"
8-
import { cacheDependencies } from "./actions_cache"
8+
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils"
9+
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
910

1011
function isPyPyVersion(versionSpec: string) {
1112
return versionSpec.startsWith("pypy")
1213
}
1314

14-
// function resolveVersionInput(version: string): string {
15-
// let versionFile = getInput("python-version-file")
15+
/*
16+
function resolveVersionInput(version: string): string {
17+
let versionFile = getInput("python-version-file")
1618
17-
// if (version && versionFile) {
18-
// warning("Both python-version and python-version-file inputs are specified, only python-version will be used")
19-
// }
19+
if (version && versionFile) {
20+
warning("Both python-version and python-version-file inputs are specified, only python-version will be used")
21+
}
2022
21-
// if (version) {
22-
// return version
23-
// }
23+
if (version) {
24+
return version
25+
}
2426
25-
// versionFile = versionFile || ".python-version"
26-
// if (!existsSync(versionFile)) {
27-
// throw new Error(`The specified python version file at: ${versionFile} does not exist`)
28-
// }
29-
// version = readFileSync(versionFile, "utf8")
30-
// info(`Resolved ${versionFile} as ${version}`)
27+
versionFile = versionFile || ".python-version"
28+
if (!existsSync(versionFile)) {
29+
throw new Error(`The specified python version file at: ${versionFile} does not exist`)
30+
}
31+
version = readFileSync(versionFile, "utf8")
32+
info(`Resolved ${versionFile} as ${version}`)
3133
32-
// return version
33-
// }
34+
return version
35+
}
36+
*/
37+
38+
export async function cacheDependencies(cache: string, pythonVersion: string) {
39+
const cacheDependencyPath = undefined // core.getInput("cache-dependency-path") || undefined
40+
const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
41+
await cacheDistributor.restoreCache()
42+
}
3443

3544
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
36-
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
37-
debug(`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env.AGENT_TOOLSDIRECTORY}`)
45+
// According to the README windows binaries do not require to be installed
46+
// in the specific location, but Mac and Linux do
47+
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) {
48+
if (IS_LINUX) {
49+
process.env.AGENT_TOOLSDIRECTORY = "/opt/hostedtoolcache"
50+
} else {
51+
process.env.AGENT_TOOLSDIRECTORY = "/Users/runner/hostedtoolcache"
52+
}
3853
process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
39-
} else {
40-
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE==${process.env.RUNNER_TOOL_CACHE}`)
4154
}
55+
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env.RUNNER_TOOL_CACHE}`)
4256
// const version = resolveVersionInput(versionGiven)
4357
if (version) {
4458
let pythonVersion: string
4559
if (isPyPyVersion(version)) {
46-
const installed = await findPyPyVersion(version, arch)
60+
const installed = await findPyPyVersion(version, arch, true)
4761
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
4862
info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
4963
} else {
50-
const installed = await useCpythonVersion(version, arch)
64+
const installed = await useCpythonVersion(version, arch, true)
5165
pythonVersion = installed.version
5266
info(`Successfully set up ${installed.impl} (${pythonVersion})`)
5367
}
5468

55-
const cache = "pip" // core.getInput("cache") // package manager used for caching
56-
57-
await cacheDependencies(cache, pythonVersion)
69+
if (isCacheFeatureAvailable()) {
70+
const cache = "pip" // core.getInput("cache") // package manager used for caching
71+
await cacheDependencies(cache, pythonVersion)
72+
}
5873
}
5974

6075
if (isGitHubCI()) {

0 commit comments

Comments
 (0)