PythonCore PyPackageManager pick up newly installed dependencies


I'm currently extending a plugin to take generated code from a remote URL, save it and add a required Python dependency.

I eventually worked out that `executeOnPooledThread` rather than `runWriteAction` is needed to call `PyPackageManager.install` without threading problems but after this process has completed successfully the IDE is in a state that it doesn't know newly installed packages are available without a "Refresh from disk" on the project.

I've tried using `pyPackageManager.refreshAndGetPackages(false)` and `VirtualFileManager.getInstance().syncRefresh();` without any success. I was wondering if anyone could point me in the right directory to kick off a process that would make the IDE aware of the new dependencies and I guess re-analyze the newly added code to show that it is valid or not.

Many thanks!

Comment actions Permalink

Please show your relevant portion of code. AFAIU you'll need to perform VFS refresh on downloaded files/dir(s) first, then invoke PyPackageManager.refreshAndGetPackages() after.

Comment actions Permalink

Thanks Yann Cebron, I've got something working so far, but also my order was probably not right. I used an `invokeLater` with a delay to then run:


I'll fix it up to order of calls order as previously the refresh was happening after the install/refreshAndGetPackages to hopefully make it more responsive and less hacky. Really appreciate the help!


Please sign in to leave a comment.