Skip to content

Commit 9a6f974

Browse files
authored
Merge pull request #28 from aminya/fix-python-windows
2 parents 3c105b2 + 8091550 commit 9a6f974

File tree

6 files changed

+68
-53
lines changed

6 files changed

+68
-53
lines changed

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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,18 @@
3535
"@actions/io": "^1.1.1",
3636
"@actions/tool-cache": "^1.7.1",
3737
"execa": "^5.1.1",
38-
"hasha": "^5.2.2",
3938
"mri": "^1.2.0",
4039
"msvc-dev-cmd": "git://github.com/aminya/msvc-dev-cmd#9f672c1",
4140
"semver": "^7.3.5",
42-
"setup-python": "https://github.com/actions/setup-python",
41+
"setup-python": "https://github.com/actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a",
4342
"untildify": "^4.0.0",
4443
"which": "^2.0.2"
4544
},
4645
"devDependencies": {
4746
"@types/cross-spawn": "^6.0.2",
4847
"@types/jest": "^27.4.0",
4948
"@types/mri": "^1.1.1",
50-
"@types/node": "^17.0.13",
49+
"@types/node": "^17.0.14",
5150
"@types/semver": "^7.3.9",
5251
"@types/which": "^2.0.1",
5352
"caxa": "^2.1.0",

pnpm-lock.yaml

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

src/python/actions_python.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
import * as core from "@actions/core"
22
import * as finder from "setup-python/src/find-python"
33
import * as finderPyPy from "setup-python/src/find-pypy"
4-
// import * as path from "path"
4+
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
5+
// import { isGhes } from "setup-python/src/utils"
56

67
function isPyPyVersion(versionSpec: string) {
78
return versionSpec.startsWith("pypy-")
89
}
910

11+
// // @ts-ignore
12+
// async function cacheDependencies(cache: string, pythonVersion: string) {
13+
// if (isGhes()) {
14+
// throw new Error("Caching is not supported on GHES")
15+
// }
16+
// const cacheDependencyPath = core.getInput("cache-dependency-path") || undefined
17+
// const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
18+
// await cacheDistributor.restoreCache()
19+
// }
20+
1021
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
22+
let pythonVersion: string
1123
if (isPyPyVersion(version)) {
1224
const installed = await finderPyPy.findPyPyVersion(version, arch)
25+
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
1326
core.info(
1427
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
1528
)
1629
} else {
1730
const installed = await finder.findPythonVersion(version, arch)
18-
core.info(`Successfully setup ${installed.impl} (${installed.version})`)
31+
pythonVersion = installed.version
32+
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
1933
}
34+
35+
// const cache = core.getInput("cache")
36+
// if (cache) {
37+
// await cacheDependencies(cache, pythonVersion)
38+
// }
39+
2040
// fails
41+
// const matchersPath = path.join(__dirname, '../..', '.github');
42+
// core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
2143
// core.info(`##[add-matcher]${path.join("./.github", "python.json")}`)
44+
2245
return undefined
2346
}

src/python/python.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import { addPath } from "../utils/path/addPath"
33
import { setupAptPack } from "../utils/setup/setupAptPack"
44
import { setupBrewPack } from "../utils/setup/setupBrewPack"
55
import { setupChocoPack } from "../utils/setup/setupChocoPack"
6-
import hasha from "hasha"
7-
import { join } from "path"
86
import { isGitHubCI } from "../utils/env/isci"
97

108
export function setupPython(version: string, setupDir: string, arch: string) {
11-
if (!isGitHubCI()) {
12-
// TODO parse versoin
13-
return setupPythonViaSystem("", setupDir, arch)
9+
if (!isGitHubCI() || process.platform === "win32") {
10+
// TODO parse version
11+
return setupPythonViaSystem(version, setupDir, arch)
1412
}
1513
try {
1614
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -21,20 +19,15 @@ export function setupPython(version: string, setupDir: string, arch: string) {
2119
}
2220
}
2321

24-
export async function setupPythonViaSystem(version: string, setupDir: string, arch: string) {
22+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
23+
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
2524
switch (process.platform) {
2625
case "win32": {
27-
// Get an unique output directory name from the URL.
28-
const key: string = await hasha.async(version + arch, { algorithm: "md5" })
29-
const installDir = join(setupDir, key, "python")
30-
const binDir = installDir
31-
await setupChocoPack("python3", version, [`/InstallDir:${installDir}`])
32-
26+
await setupChocoPack("python3", version, [`/InstallDir:${setupDir}`])
3327
// Adding the bin dir to the path
3428
/** The directory which the tool is installed to */
35-
activateWinPython(binDir)
36-
37-
return { installDir, binDir }
29+
activateWinPython(setupDir)
30+
return { installDir: setupDir, binDir: setupDir }
3831
}
3932
case "darwin": {
4033
return setupBrewPack("python3", version)

0 commit comments

Comments
 (0)