diff --git a/python/python-sdk/src/com/jetbrains/python/packaging/PyCondaPackageService.java b/python/python-sdk/src/com/jetbrains/python/packaging/PyCondaPackageService.java index 030deeabe4d6..3424fd4ffb52 100644 --- a/python/python-sdk/src/com/jetbrains/python/packaging/PyCondaPackageService.java +++ b/python/python-sdk/src/com/jetbrains/python/packaging/PyCondaPackageService.java @@ -80,13 +80,18 @@ public class PyCondaPackageService implements PersistentStateComponent): List { fun detectCondaEnvs(module: Module?, existingSdks: List, context: UserDataHolder): List = filterSuggestedPaths(CondaEnvSdkFlavor.getInstance().suggestHomePaths(module, context), existingSdks, module, true) +fun guessCondaBaseEnvironment(condaPath: String): Sdk? { + if (!condaPath.endsWith(File.separatorChar + getCondaName())) { + return null + } + + val interpreterPath = condaPath.replaceAfterLast(File.separatorChar, getPythonName()) + val condaVirtualFile = VfsUtil.findFileByIoFile(File(interpreterPath), false) + if (condaVirtualFile != null && condaVirtualFile.exists()) { + return PyDetectedSdk(condaVirtualFile.path) + } + return null +} + fun filterAssociatedSdks(module: Module, existingSdks: List): List { return existingSdks.filter { it.sdkType is PythonSdkType && it.isAssociatedWithModule(module) } } diff --git a/python/src/com/jetbrains/python/sdk/add/PyAddSdkPanel.kt b/python/src/com/jetbrains/python/sdk/add/PyAddSdkPanel.kt index 65152cdf086d..73caacb33c46 100644 --- a/python/src/com/jetbrains/python/sdk/add/PyAddSdkPanel.kt +++ b/python/src/com/jetbrains/python/sdk/add/PyAddSdkPanel.kt @@ -141,6 +141,7 @@ fun addInterpretersAsync(sdkComboBox: PySdkPathChoosingComboBox, finally { executor.execute { sdkComboBox.setBusy(false) + sdkComboBox.childComponent.removeAllItems() sdks.forEach(sdkComboBox.childComponent::addItem) onAdded() }