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 @@ -214,3 +214,17 @@ export async function getProjectInstallable(
214214 ) ;
215215 return installable ;
216216}
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