Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update setup-python to fix pip windows issues #28

Merged
merged 3 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@
"@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"
},
"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",
Expand Down
62 changes: 31 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 25 additions & 2 deletions src/python/actions_python.ts
Original file line number Diff line number Diff line change
@@ -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
}
23 changes: 8 additions & 15 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down