Merge pull request #28 from aminya/fix-python-windows

This commit is contained in:
Amin Yahyaabadi 2022-02-04 12:44:04 -08:00 committed by GitHub
commit 9a6f97440c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 53 deletions

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

@ -35,11 +35,10 @@
"@actions/io": "^1.1.1",
"@actions/tool-cache": "^1.7.1",
"execa": "^5.1.1",
"hasha": "^5.2.2",
"mri": "^1.2.0",
"msvc-dev-cmd": "git://github.com/aminya/msvc-dev-cmd#9f672c1",
"semver": "^7.3.5",
"setup-python": "https://github.com/actions/setup-python",
"setup-python": "https://github.com/actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a",
"untildify": "^4.0.0",
"which": "^2.0.2"
},
@ -47,7 +46,7 @@
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^27.4.0",
"@types/mri": "^1.1.1",
"@types/node": "^17.0.13",
"@types/node": "^17.0.14",
"@types/semver": "^7.3.9",
"@types/which": "^2.0.1",
"caxa": "^2.1.0",

View File

@ -11,7 +11,7 @@ specifiers:
'@types/cross-spawn': ^6.0.2
'@types/jest': ^27.4.0
'@types/mri': ^1.1.1
'@types/node': ^17.0.13
'@types/node': ^17.0.14
'@types/semver': ^7.3.9
'@types/which': ^2.0.1
caxa: ^2.1.0
@ -27,7 +27,7 @@ specifiers:
parcel: ^2.2.1
prettier-config-atomic: ^3.0.3
semver: 7.3.5
setup-python: https://github.com/actions/setup-python
setup-python: https://github.com/actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a
shx: 0.3.4
terser-config-atomic: ^0.1.1
ts-jest: ^27.1.3
@ -45,7 +45,7 @@ dependencies:
mri: 1.2.0
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
semver: 7.3.5
setup-python: github.com/actions/setup-python/156361d073e2d704ec0bfe646b4500cdc0547324
setup-python: github.com/actions/setup-python/7f80679172b057fc5e90d70d197929d454754a5a
untildify: 4.0.0
which: 2.0.2
@ -53,7 +53,7 @@ devDependencies:
'@types/cross-spawn': 6.0.2
'@types/jest': 27.4.0
'@types/mri': 1.1.1
'@types/node': 17.0.13
'@types/node': 17.0.14
'@types/semver': 7.3.9
'@types/which': 2.0.1
caxa: 2.1.0
@ -721,7 +721,7 @@ packages:
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dependencies:
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
chalk: 4.1.2
jest-message-util: 27.4.6
jest-util: 27.4.2
@ -742,7 +742,7 @@ packages:
'@jest/test-result': 27.4.6
'@jest/transform': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
ansi-escapes: 4.3.2
chalk: 4.1.2
emittery: 0.8.1
@ -779,7 +779,7 @@ packages:
dependencies:
'@jest/fake-timers': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
jest-mock: 27.4.6
dev: true
@ -789,7 +789,7 @@ packages:
dependencies:
'@jest/types': 27.4.2
'@sinonjs/fake-timers': 8.0.1
'@types/node': 17.0.13
'@types/node': 17.0.14
jest-message-util: 27.4.6
jest-mock: 27.4.6
jest-util: 27.4.2
@ -818,7 +818,7 @@ packages:
'@jest/test-result': 27.4.6
'@jest/transform': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
chalk: 4.1.2
collect-v8-coverage: 1.0.1
exit: 0.1.2
@ -902,7 +902,7 @@ packages:
dependencies:
'@types/istanbul-lib-coverage': 2.0.3
'@types/istanbul-reports': 3.0.1
'@types/node': 17.0.13
'@types/node': 17.0.14
'@types/yargs': 16.0.4
chalk: 4.1.2
dev: true
@ -1771,26 +1771,26 @@ packages:
/@types/cross-spawn/6.0.2:
resolution: {integrity: sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
dev: true
/@types/glob/7.1.4:
resolution: {integrity: sha512-w+LsMxKyYQm347Otw+IfBXOv9UWVjpHpCDdbBMt8Kz/xbvCYNjP+0qPh91Km3iKfSRLBB0P7fAMf0KHrPu+MyA==}
dependencies:
'@types/minimatch': 3.0.5
'@types/node': 17.0.13
'@types/node': 17.0.14
dev: true
/@types/graceful-fs/4.1.5:
resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
dev: true
/@types/http-proxy/1.17.7:
resolution: {integrity: sha512-9hdj6iXH64tHSLTY+Vt2eYOGzSogC+JQ2H7bdPWkuh7KXP5qLllWx++t+K9Wk556c3dkDdPws/SpMRi0sdCT1w==}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
dev: true
/@types/istanbul-lib-coverage/2.0.3:
@ -1841,12 +1841,12 @@ packages:
/@types/node-fetch/2.5.12:
resolution: {integrity: sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
form-data: 3.0.1
dev: false
/@types/node/17.0.13:
resolution: {integrity: sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==}
/@types/node/17.0.14:
resolution: {integrity: sha512-SbjLmERksKOGzWzPNuW7fJM7fk3YXVTFiZWB/Hs99gwhk+/dnrQRPBQjPW9aO+fi1tAffi9PrwFvsmOKmDTyng==}
/@types/normalize-package-data/2.4.1:
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
@ -1871,7 +1871,7 @@ packages:
/@types/tunnel/0.0.3:
resolution: {integrity: sha512-sOUTGn6h1SfQ+gbgqC364jLFBw2lnFqkgF3q0WovEHRLMrVD1sd5aufqi/aJObLekJO+Aq5z646U4Oxy6shXMA==}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
dev: false
/@types/unist/2.0.6:
@ -4937,7 +4937,7 @@ packages:
'@jest/environment': 27.4.6
'@jest/test-result': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
chalk: 4.1.2
co: 4.6.0
dedent: 0.7.0
@ -5070,7 +5070,7 @@ packages:
'@jest/environment': 27.4.6
'@jest/fake-timers': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
jest-mock: 27.4.6
jest-util: 27.4.2
jsdom: 16.7.0
@ -5088,7 +5088,7 @@ packages:
'@jest/environment': 27.4.6
'@jest/fake-timers': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
jest-mock: 27.4.6
jest-util: 27.4.2
dev: true
@ -5104,7 +5104,7 @@ packages:
dependencies:
'@jest/types': 27.4.2
'@types/graceful-fs': 4.1.5
'@types/node': 17.0.13
'@types/node': 17.0.14
anymatch: 3.1.2
fb-watchman: 2.0.1
graceful-fs: 4.2.8
@ -5126,7 +5126,7 @@ packages:
'@jest/source-map': 27.4.0
'@jest/test-result': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
chalk: 4.1.2
co: 4.6.0
expect: 27.4.6
@ -5181,7 +5181,7 @@ packages:
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dependencies:
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
dev: true
/jest-pnp-resolver/1.2.2_jest-resolve@27.4.6:
@ -5237,7 +5237,7 @@ packages:
'@jest/test-result': 27.4.6
'@jest/transform': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
chalk: 4.1.2
emittery: 0.8.1
exit: 0.1.2
@ -5295,7 +5295,7 @@ packages:
resolution: {integrity: sha512-RDhpcn5f1JYTX2pvJAGDcnsNTnsV9bjYPU8xcV+xPwOXnUPOQwf4ZEuiU6G9H1UztH+OapMgu/ckEVwO87PwnQ==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
graceful-fs: 4.2.8
dev: true
@ -5334,7 +5334,7 @@ packages:
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dependencies:
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
chalk: 4.1.2
ci-info: 3.2.0
graceful-fs: 4.2.8
@ -5359,7 +5359,7 @@ packages:
dependencies:
'@jest/test-result': 27.4.6
'@jest/types': 27.4.2
'@types/node': 17.0.13
'@types/node': 17.0.14
ansi-escapes: 4.3.2
chalk: 4.1.2
jest-util: 27.4.2
@ -5370,7 +5370,7 @@ packages:
resolution: {integrity: sha512-gHWJF/6Xi5CTG5QCvROr6GcmpIqNYpDJyc8A1h/DyXqH1tD6SnRCM0d3U5msV31D2LB/U+E0M+W4oyvKV44oNw==}
engines: {node: '>= 10.13.0'}
dependencies:
'@types/node': 17.0.13
'@types/node': 17.0.14
merge-stream: 2.0.0
supports-color: 8.1.1
dev: true
@ -8133,8 +8133,8 @@ packages:
readable-stream: 3.6.0
dev: true
github.com/actions/setup-python/156361d073e2d704ec0bfe646b4500cdc0547324:
resolution: {tarball: https://codeload.github.com/actions/setup-python/tar.gz/156361d073e2d704ec0bfe646b4500cdc0547324}
github.com/actions/setup-python/7f80679172b057fc5e90d70d197929d454754a5a:
resolution: {tarball: https://codeload.github.com/actions/setup-python/tar.gz/7f80679172b057fc5e90d70d197929d454754a5a}
name: setup-python
version: 2.2.2
dependencies:

View File

@ -1,23 +1,46 @@
import * as core from "@actions/core"
import * as finder from "setup-python/src/find-python"
import * as finderPyPy from "setup-python/src/find-pypy"
// import * as path from "path"
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
// import { isGhes } from "setup-python/src/utils"
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy-")
}
// // @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()
// }
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
let pythonVersion: string
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
core.info(
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
)
} else {
const installed = await finder.findPythonVersion(version, arch)
core.info(`Successfully setup ${installed.impl} (${installed.version})`)
pythonVersion = installed.version
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`)
}
// const cache = core.getInput("cache")
// if (cache) {
// await cacheDependencies(cache, pythonVersion)
// }
// fails
// const matchersPath = path.join(__dirname, '../..', '.github');
// core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
// core.info(`##[add-matcher]${path.join("./.github", "python.json")}`)
return undefined
}

View File

@ -3,14 +3,12 @@ import { addPath } from "../utils/path/addPath"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import hasha from "hasha"
import { join } from "path"
import { isGitHubCI } from "../utils/env/isci"
export function setupPython(version: string, setupDir: string, arch: string) {
if (!isGitHubCI()) {
// TODO parse versoin
return setupPythonViaSystem("", setupDir, arch)
if (!isGitHubCI() || process.platform === "win32") {
// TODO parse version
return setupPythonViaSystem(version, setupDir, arch)
}
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
@ -21,20 +19,15 @@ export function setupPython(version: string, setupDir: string, arch: string) {
}
}
export async function setupPythonViaSystem(version: string, setupDir: string, arch: string) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
switch (process.platform) {
case "win32": {
// Get an unique output directory name from the URL.
const key: string = await hasha.async(version + arch, { algorithm: "md5" })
const installDir = join(setupDir, key, "python")
const binDir = installDir
await setupChocoPack("python3", version, [`/InstallDir:${installDir}`])
await setupChocoPack("python3", version, [`/InstallDir:${setupDir}`])
// Adding the bin dir to the path
/** The directory which the tool is installed to */
activateWinPython(binDir)
return { installDir, binDir }
activateWinPython(setupDir)
return { installDir: setupDir, binDir: setupDir }
}
case "darwin": {
return setupBrewPack("python3", version)