File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import { UvProjectCreator } from './uvProjectCreator';
9
9
import { isUvInstalled } from './helpers' ;
10
10
import { createFileSystemWatcher , onDidDeleteFiles } from '../../common/workspace.apis' ;
11
11
import { createSimpleDebounce } from '../../common/utils/debounce' ;
12
+ import { onDidEndTerminalShellExecution } from '../../common/window.apis' ;
13
+ import { isPipInstallCommand } from './pipUtils' ;
12
14
13
15
export async function registerSystemPythonFeatures (
14
16
nativeFinder : NativePythonFinder ,
@@ -43,6 +45,18 @@ export async function registerSystemPythonFeatures(
43
45
} ) ,
44
46
) ;
45
47
48
+ disposables . push (
49
+ onDidEndTerminalShellExecution ( async ( e ) => {
50
+ const cwd = e . terminal . shellIntegration ?. cwd ;
51
+ if ( isPipInstallCommand ( e . execution . commandLine . value ) && cwd ) {
52
+ const env = await venvManager . get ( cwd ) ;
53
+ if ( env ) {
54
+ await pkgManager . refresh ( env ) ;
55
+ }
56
+ }
57
+ } ) ,
58
+ ) ;
59
+
46
60
setImmediate ( async ( ) => {
47
61
if ( await isUvInstalled ( log ) ) {
48
62
disposables . push ( api . registerPythonProjectCreator ( new UvProjectCreator ( api , log ) ) ) ;
Original file line number Diff line number Diff line change @@ -214,3 +214,17 @@ export async function getProjectInstallable(
214
214
) ;
215
215
return installable ;
216
216
}
217
+
218
+ export function isPipInstallCommand ( command : string ) : boolean {
219
+ // Regex to match pip install commands, capturing variations like:
220
+ // pip install package
221
+ // python -m pip install package
222
+ // pip3 install package
223
+ // py -m pip install package
224
+ // pip install -r requirements.txt
225
+ // uv pip install package
226
+ // poetry run pip install package
227
+ // pipx run pip install package
228
+ // Any other tool that might wrap pip install
229
+ return / (?: ^ | \s ) (?: \S + \s + ) * (?: p i p \d * ) \s + ( i n s t a l l | u n i n s t a l l ) \b / . test ( command ) ;
230
+ }
You can’t perform that action at this time.
0 commit comments