File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 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';
99import { isUvInstalled } from './helpers' ;
1010import { createFileSystemWatcher , onDidDeleteFiles } from '../../common/workspace.apis' ;
1111import { createSimpleDebounce } from '../../common/utils/debounce' ;
12+ import { onDidEndTerminalShellExecution } from '../../common/window.apis' ;
13+ import { isPipInstallCommand } from './pipUtils' ;
1214
1315export async function registerSystemPythonFeatures (
1416 nativeFinder : NativePythonFinder ,
@@ -43,6 +45,18 @@ export async function registerSystemPythonFeatures(
4345 } ) ,
4446 ) ;
4547
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+
4660 setImmediate ( async ( ) => {
4761 if ( await isUvInstalled ( log ) ) {
4862 disposables . push ( api . registerPythonProjectCreator ( new UvProjectCreator ( api , log ) ) ) ;
Original file line number Diff line number Diff line change @@ -207,3 +207,17 @@ export async function getProjectInstallable(
207207 ) ;
208208 return installable ;
209209}
210+
211+ export function isPipInstallCommand ( command : string ) : boolean {
212+ // Regex to match pip install commands, capturing variations like:
213+ // pip install package
214+ // python -m pip install package
215+ // pip3 install package
216+ // py -m pip install package
217+ // pip install -r requirements.txt
218+ // uv pip install package
219+ // poetry run pip install package
220+ // pipx run pip install package
221+ // Any other tool that might wrap pip install
222+ 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 ) ;
223+ }
You can’t perform that action at this time.
0 commit comments