Skip to content

Commit a486582

Browse files
committed
fix: do not override pipx paths if env variables are specified
1 parent 0324d60 commit a486582

File tree

7 files changed

+86
-72
lines changed

7 files changed

+86
-72
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: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,9 @@ export async function setupPipPackWithPython(
6161
const env = process.env
6262

6363
if (isPipx && user) {
64-
const pipxHome = await getPipxHome()
65-
await mkdirp(pipxHome)
66-
await mkdirp(join(pipxHome, "trash"))
67-
await mkdirp(join(pipxHome, "shared"))
68-
await mkdirp(join(pipxHome, "venv"))
69-
7064
// install to user home
71-
env.PIPX_HOME = pipxHome
72-
73-
const pipxBinDir = getPipxBinDir()
74-
await addPath(pipxBinDir)
75-
await mkdirp(pipxBinDir)
76-
77-
env.PIPX_BIN_DIR = pipxBinDir
65+
env.PIPX_HOME = await getPipxHome()
66+
env.PIPX_BIN_DIR = await getPipxBinDir()
7867
}
7968

8069
execaSync(givenPython, ["-m", pip, ...upgradeFlag, ...userFlag, nameAndVersion], {
@@ -106,26 +95,51 @@ export async function hasPipx(givenPython: string) {
10695
}
10796

10897
async function getPipxHome_raw() {
98+
let pipxHome = process.env.PIPX_HOME
99+
if (pipxHome !== undefined) {
100+
return pipxHome
101+
}
102+
109103
// Based on https://pipx.pypa.io/stable/installation/
110104
const compatHome = untildifyUser("~/.local/pipx")
111105
if (await pathExists(compatHome)) {
112106
return compatHome
113107
}
114108

115109
switch (process.platform) {
116-
case "win32":
117-
return untildifyUser("~/AppData/Local/pipx")
118-
case "darwin":
119-
return untildifyUser("~/Library/Application Support/pipx")
120-
default:
121-
return untildifyUser("~/.local/share/pipx")
110+
case "win32": {
111+
pipxHome = untildifyUser("~/AppData/Local/pipx")
112+
break
113+
}
114+
case "darwin": {
115+
pipxHome = untildifyUser("~/Library/Application Support/pipx")
116+
break
117+
}
118+
default: {
119+
pipxHome = untildifyUser("~/.local/share/pipx")
120+
break
121+
}
122122
}
123+
124+
await mkdirp(pipxHome)
125+
await mkdirp(join(pipxHome, "trash"))
126+
await mkdirp(join(pipxHome, "shared"))
127+
await mkdirp(join(pipxHome, "venv"))
128+
return pipxHome
123129
}
124130
const getPipxHome = memoize(getPipxHome_raw, { isPromise: true })
125131

126-
function getPipxBinDir() {
127-
return untildifyUser("~/.local/bin")
132+
async function getPipxBinDir_raw() {
133+
if (process.env.PIPX_BIN_DIR !== undefined) {
134+
return process.env.PIPX_BIN_DIR
135+
}
136+
137+
const pipxBinDir = untildifyUser("~/.local/bin")
138+
await addPath(pipxBinDir)
139+
await mkdirp(pipxBinDir)
140+
return pipxBinDir
128141
}
142+
const getPipxBinDir = memoize(getPipxBinDir_raw, { isPromise: true })
129143

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

0 commit comments

Comments
 (0)