@@ -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+
174186async function pipPackageIsInstalled ( python : string , name : string ) {
175187 try {
176188 const result = await execa ( python , [ "-m" , "pip" , "-qq" , "show" , name ] , {
0 commit comments