Skip to content

Commit 4d73853

Browse files
committed
fix: remove the pkg extension from the pip pkg names
1 parent 4ebcbc1 commit 4d73853

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

dist/legacy/setup-cpp.js

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.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.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.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: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,21 @@ export async function setupPipPackWithPython(
5353

5454
const pip = isPipx ? "pipx" : "pip"
5555

56+
// remove `[]` extensions
57+
const nameOnly = getPackageName(name)
58+
5659
// if upgrade is not requested, check if the package is already installed, and return if it is
5760
if (!upgrade) {
5861
const installed = isPipx
59-
? await pipxPackageInstalled(givenPython, name)
60-
: await pipPackageIsInstalled(givenPython, name)
62+
? await pipxPackageInstalled(givenPython, nameOnly)
63+
: await pipPackageIsInstalled(givenPython, nameOnly)
6164
if (installed) {
62-
const binDir = await finishPipPackageInstall(givenPython, name)
65+
const binDir = await finishPipPackageInstall(givenPython, nameOnly)
6366
return { binDir }
6467
}
6568
}
6669

67-
const hasPackage = await pipHasPackage(givenPython, name)
70+
const hasPackage = await pipHasPackage(givenPython, nameOnly)
6871
if (hasPackage) {
6972
try {
7073
info(`Installing ${name} ${version ?? ""} via ${pip}`)
@@ -96,7 +99,7 @@ export async function setupPipPackWithPython(
9699
throw new Error(`Failed to install ${name} as it was not found via ${pip} or the system package manager`)
97100
}
98101

99-
const binDir = await finishPipPackageInstall(givenPython, name)
102+
const binDir = await finishPipPackageInstall(givenPython, nameOnly)
100103
return { binDir }
101104
}
102105

@@ -171,6 +174,15 @@ async function getPython(): Promise<string> {
171174
return pythonBin
172175
}
173176

177+
/**
178+
* Get the actual name of a pip package from the given string
179+
* @param pkg the given name that might contain extensions in `[]`.
180+
* @returns stirped down name of the package
181+
*/
182+
function getPackageName(pkg: string) {
183+
return pkg.replace(/\[.*]/g, "").trim()
184+
}
185+
174186
async function pipPackageIsInstalled(python: string, name: string) {
175187
try {
176188
const result = await execa(python, ["-m", "pip", "-qq", "show", name], {

0 commit comments

Comments
 (0)