Skip to content

Commit

Permalink
fix: fix PIPX_HOME on Windows and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 23, 2024
1 parent 1a3ed1a commit f3a5dc3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 53 deletions.
32 changes: 16 additions & 16 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export async function setupPipPackWithPython(

if (isPipx && user) {
// install to user home
env.PIPX_HOME = untildifyUser("~/.local/pipx")
env.PIPX_BIN_DIR = untildifyUser("~/.local/bin")
env.PIPX_HOME = await getPipxHome()
env.PIPX_BIN_DIR = getPipxBinDir()
}

execaSync(givenPython, ["-m", pip, ...upgradeFlag, ...userFlag, nameAndVersion], {
Expand Down Expand Up @@ -93,6 +93,28 @@ export async function hasPipx(givenPython: string) {
return (await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })).exitCode === 0
}

async function getPipxHome_raw() {
// Based on https://pipx.pypa.io/stable/installation/
const compatHome = untildifyUser("~/.local/pipx")
if (await pathExists(compatHome)) {
return compatHome
}

switch (process.platform) {
case "win32":
return untildifyUser("~/AppData/Local/pipx")
case "darwin":
return untildifyUser("~/Library/Application Support/pipx")
default:
return untildifyUser("~/.local/share/pipx")
}
}
const getPipxHome = memoize(getPipxHome_raw, { isPromise: true })

function getPipxBinDir() {
return untildifyUser("~/.local/bin")
}

async function getPython_raw(): Promise<string> {
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
if (pythonBin === undefined) {
Expand Down

0 comments on commit f3a5dc3

Please sign in to comment.