diff --git a/python/ide/impl/resources/META-INF/pycharm-community-customization.xml b/python/ide/impl/resources/META-INF/pycharm-community-customization.xml index 8e6c96706edb..2c3fe5e8169a 100644 --- a/python/ide/impl/resources/META-INF/pycharm-community-customization.xml +++ b/python/ide/impl/resources/META-INF/pycharm-community-customization.xml @@ -1,5 +1,5 @@ - + @@ -13,6 +13,12 @@ + + + com.jetbrains.python.PythonSdkConfigurator + + + - ): Sdk? { + private fun findExistingAssociatedSdk(module: Module, existingSdks: List): Sdk? { return existingSdks .asSequence() .filter { it.sdkType is PythonSdkType && it.isAssociatedWithModule(module) } @@ -33,7 +32,7 @@ class PythonSdkConfigurator : DirectoryProjectConfigurator { .firstOrNull() } - fun findDetectedAssociatedEnvironment(module: Module, existingSdks: List, context: UserDataHolder): PyDetectedSdk? { + private fun findDetectedAssociatedEnvironment(module: Module, existingSdks: List, context: UserDataHolder): PyDetectedSdk? { // TODO: Move all interpreter detection away from EDT & use proper synchronization for that val progress = ProgressManager.getInstance() return progress.run(object : Task.WithResult(module.project, @@ -63,12 +62,19 @@ class PythonSdkConfigurator : DirectoryProjectConfigurator { detectSystemWideSdks(module, existingSdks, context).firstOrNull() } - override fun configureProject(project: Project, - baseDir: VirtualFile, - moduleRef: Ref, - newProject: Boolean) { + init { + ApplicationManager.getApplication().messageBus.connect().subscribe(ProjectManager.TOPIC, object : ProjectManagerListener { + override fun projectOpened(project: Project) { + if (!project.isDefault) { + configureSdk(project) + } + } + }) + } + + private fun configureSdk(project: Project) { val context = UserDataHolderBase() - if (project.pythonSdk != null || newProject) { + if (project.pythonSdk != null) { return } val module = ModuleManager.getInstance(project).modules.firstOrNull() ?: return