mirror of https://github.com/aminya/setup-cpp
fix: do not override pipx paths if env variables are specified
This commit is contained in:
parent
0324d60e51
commit
a486582e84
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -61,20 +61,9 @@ export async function setupPipPackWithPython(
|
||||||
const env = process.env
|
const env = process.env
|
||||||
|
|
||||||
if (isPipx && user) {
|
if (isPipx && user) {
|
||||||
const pipxHome = await getPipxHome()
|
|
||||||
await mkdirp(pipxHome)
|
|
||||||
await mkdirp(join(pipxHome, "trash"))
|
|
||||||
await mkdirp(join(pipxHome, "shared"))
|
|
||||||
await mkdirp(join(pipxHome, "venv"))
|
|
||||||
|
|
||||||
// install to user home
|
// install to user home
|
||||||
env.PIPX_HOME = pipxHome
|
env.PIPX_HOME = await getPipxHome()
|
||||||
|
env.PIPX_BIN_DIR = await getPipxBinDir()
|
||||||
const pipxBinDir = getPipxBinDir()
|
|
||||||
await addPath(pipxBinDir)
|
|
||||||
await mkdirp(pipxBinDir)
|
|
||||||
|
|
||||||
env.PIPX_BIN_DIR = pipxBinDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
execaSync(givenPython, ["-m", pip, ...upgradeFlag, ...userFlag, nameAndVersion], {
|
execaSync(givenPython, ["-m", pip, ...upgradeFlag, ...userFlag, nameAndVersion], {
|
||||||
|
@ -106,6 +95,11 @@ export async function hasPipx(givenPython: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPipxHome_raw() {
|
async function getPipxHome_raw() {
|
||||||
|
let pipxHome = process.env.PIPX_HOME
|
||||||
|
if (pipxHome !== undefined) {
|
||||||
|
return pipxHome
|
||||||
|
}
|
||||||
|
|
||||||
// Based on https://pipx.pypa.io/stable/installation/
|
// Based on https://pipx.pypa.io/stable/installation/
|
||||||
const compatHome = untildifyUser("~/.local/pipx")
|
const compatHome = untildifyUser("~/.local/pipx")
|
||||||
if (await pathExists(compatHome)) {
|
if (await pathExists(compatHome)) {
|
||||||
|
@ -113,20 +107,40 @@ async function getPipxHome_raw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32":
|
case "win32": {
|
||||||
return untildifyUser("~/AppData/Local/pipx")
|
pipxHome = untildifyUser("~/AppData/Local/pipx")
|
||||||
case "darwin":
|
break
|
||||||
return untildifyUser("~/Library/Application Support/pipx")
|
|
||||||
default:
|
|
||||||
return untildifyUser("~/.local/share/pipx")
|
|
||||||
}
|
}
|
||||||
|
case "darwin": {
|
||||||
|
pipxHome = untildifyUser("~/Library/Application Support/pipx")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
pipxHome = untildifyUser("~/.local/share/pipx")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await mkdirp(pipxHome)
|
||||||
|
await mkdirp(join(pipxHome, "trash"))
|
||||||
|
await mkdirp(join(pipxHome, "shared"))
|
||||||
|
await mkdirp(join(pipxHome, "venv"))
|
||||||
|
return pipxHome
|
||||||
}
|
}
|
||||||
const getPipxHome = memoize(getPipxHome_raw, { isPromise: true })
|
const getPipxHome = memoize(getPipxHome_raw, { isPromise: true })
|
||||||
|
|
||||||
function getPipxBinDir() {
|
async function getPipxBinDir_raw() {
|
||||||
return untildifyUser("~/.local/bin")
|
if (process.env.PIPX_BIN_DIR !== undefined) {
|
||||||
|
return process.env.PIPX_BIN_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pipxBinDir = untildifyUser("~/.local/bin")
|
||||||
|
await addPath(pipxBinDir)
|
||||||
|
await mkdirp(pipxBinDir)
|
||||||
|
return pipxBinDir
|
||||||
|
}
|
||||||
|
const getPipxBinDir = memoize(getPipxBinDir_raw, { isPromise: true })
|
||||||
|
|
||||||
async function getPython_raw(): Promise<string> {
|
async function getPython_raw(): Promise<string> {
|
||||||
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
|
const pythonBin = (await setupPython(getVersion("python", undefined, await ubuntuVersion()), "", process.arch)).bin
|
||||||
if (pythonBin === undefined) {
|
if (pythonBin === undefined) {
|
||||||
|
|
Loading…
Reference in New Issue