Skip to content

Commit f3a5dc3

Browse files
committed
fix: fix PIPX_HOME on Windows and MacOS
1 parent 1a3ed1a commit f3a5dc3

File tree

7 files changed

+75
-53
lines changed

7 files changed

+75
-53
lines changed

dist/actions/setup-cpp.js

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

dist/actions/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.

dist/legacy/setup-cpp.js

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

dist/legacy/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.

dist/modern/setup-cpp.js

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

dist/modern/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.

src/utils/setup/setupPipPack.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export async function setupPipPackWithPython(
6161

6262
if (isPipx && user) {
6363
// install to user home
64-
env.PIPX_HOME = untildifyUser("~/.local/pipx")
65-
env.PIPX_BIN_DIR = untildifyUser("~/.local/bin")
64+
env.PIPX_HOME = await getPipxHome()
65+
env.PIPX_BIN_DIR = getPipxBinDir()
6666
}
6767

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

96+
async function getPipxHome_raw() {
97+
// Based on https://pipx.pypa.io/stable/installation/
98+
const compatHome = untildifyUser("~/.local/pipx")
99+
if (await pathExists(compatHome)) {
100+
return compatHome
101+
}
102+
103+
switch (process.platform) {
104+
case "win32":
105+
return untildifyUser("~/AppData/Local/pipx")
106+
case "darwin":
107+
return untildifyUser("~/Library/Application Support/pipx")
108+
default:
109+
return untildifyUser("~/.local/share/pipx")
110+
}
111+
}
112+
const getPipxHome = memoize(getPipxHome_raw, { isPromise: true })
113+
114+
function getPipxBinDir() {
115+
return untildifyUser("~/.local/bin")
116+
}
117+
96118
async function getPython_raw(): Promise<string> {
97119
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
98120
if (pythonBin === undefined) {

0 commit comments

Comments
 (0)