Reinitialize Python SDK

It is common to run tests on Python projects with tox. If the -r flag is passed, the venvs are recreated before the runs. If these venvs are configured in PyCharm, it usually causes the IDE to start behaving inconsistently and the only thing that can be done is recreation of the venv.

I am the author of the PyVenvManage plugin and would like to provide a one click option for this operation. The question is: is it possible to reinitialize an SDK through the API or the only way to solve this is the recreation.

Thanks a lot!

0
2 comments
Avatar
Permanently deleted user

Hi!

If I correctly understand what you mean by 'reinitialize' then you can invoke 

PythonSdkType.getInstance().setupSdkPaths(sdk)

on the sdk.

Or please explain in a bit more details what do you want to achieve.

1

Thanks Dimitry! This looks promising. I will include this step in the "set interpreter" process and we'll see if it's enough. It seems like newer PyCharm releases may have a solution for this issue already. File changes have triggered the reindexing correctly so far. So a little more testing is needed on my side.

0

Please sign in to leave a comment.