diff --git a/python/pluginResources/messages/PyBundle.properties b/python/pluginResources/messages/PyBundle.properties
index 26ca6ecb62ce..0a0c6daf39c3 100644
--- a/python/pluginResources/messages/PyBundle.properties
+++ b/python/pluginResources/messages/PyBundle.properties
@@ -1759,6 +1759,7 @@ tracecontext.generating.git=Generating git
tracecontext.packaging.tool.window=Packaging Tool Window
tracecontext.packages.sdk.controller=Packages SDK Controller
tracecontext.add.local.python.sdk.dialog=Add Local Python SDK Dialog
+tracecontext.add.remote.python.sdk.dialog=Add {0} Python SDK Dialog
tracecontext.new.project.wizard=New Project Wizard
tracecontext.loading.interpreter.list=Loading Interpreter List
tracecontext.detecting.conda.executable.and.environments=Detecting Conda Executable and environments
diff --git a/python/src/com/jetbrains/python/sdk/add/v2/common.kt b/python/src/com/jetbrains/python/sdk/add/v2/common.kt
index 4c78e9cf1a1d..f07344b92142 100644
--- a/python/src/com/jetbrains/python/sdk/add/v2/common.kt
+++ b/python/src/com/jetbrains/python/sdk/add/v2/common.kt
@@ -79,7 +79,8 @@ abstract class PythonAddEnvironment
(open val model: PythonAddInt
protected suspend fun setupSdk(moduleOrProject: ModuleOrProject): PyResult {
val sdk = getOrCreateSdk(moduleOrProject).getOr { return it }
- moduleOrProject.moduleIfExists?.excludeInnerVirtualEnv(sdk)
+ moduleOrProject.project.excludeInnerVirtualEnv(sdk)
+ moduleOrProject.moduleIfExists?.let { sdk.setAssociationToModule(it) }
return Result.success(sdk)
}
diff --git a/python/src/com/jetbrains/python/sdk/add/v2/poetry/PoetryExistingEnvironmentSelector.kt b/python/src/com/jetbrains/python/sdk/add/v2/poetry/PoetryExistingEnvironmentSelector.kt
index 362139be2a7b..28ad45a02d54 100644
--- a/python/src/com/jetbrains/python/sdk/add/v2/poetry/PoetryExistingEnvironmentSelector.kt
+++ b/python/src/com/jetbrains/python/sdk/add/v2/poetry/PoetryExistingEnvironmentSelector.kt
@@ -12,6 +12,7 @@ import com.jetbrains.python.sdk.ModuleOrProject
import com.jetbrains.python.sdk.add.v2.*
import com.jetbrains.python.sdk.basePath
import com.jetbrains.python.sdk.legacy.PythonSdkUtil
+import com.jetbrains.python.sdk.moduleIfExists
import com.jetbrains.python.sdk.poetry.createPoetrySdk
import com.jetbrains.python.sdk.poetry.detectPoetryEnvs
import com.jetbrains.python.sdk.poetry.isPoetry
@@ -31,16 +32,11 @@ internal class PoetryExistingEnvironmentSelector(model: PythonMu
PythonSdkUtil.getAllSdks().find { sdk -> sdk.isPoetry && sdk.homePath == pythonBinaryPath.toString() }?.let { return Result.success(it) }
- val module = when (moduleOrProject) {
- is ModuleOrProject.ModuleAndProject -> {
- moduleOrProject.module
- }
- else -> null
- }
- val moduleBasePath = module?.basePath?.let { Path.of(it) } ?: error("module base path is not valid: ${module?.basePath}")
+ val basePathString = moduleOrProject.moduleIfExists?.basePath ?: moduleOrProject.project.basePath
+ val basePath = basePathString?.let { Path.of(it) } ?: error("module base path is not valid: $basePathString")
return createPoetrySdk(
- moduleBasePath,
+ basePath,
existingSdks = ProjectJdkTable.getInstance().allJdks.toList(),
pythonBinaryPath = pythonBinaryPath
)
diff --git a/python/src/com/jetbrains/python/sdk/poetry/poetry.kt b/python/src/com/jetbrains/python/sdk/poetry/poetry.kt
index e37ac7c7609f..453407f29bcb 100644
--- a/python/src/com/jetbrains/python/sdk/poetry/poetry.kt
+++ b/python/src/com/jetbrains/python/sdk/poetry/poetry.kt
@@ -46,15 +46,15 @@ suspend fun createNewPoetrySdk(
@Internal
suspend fun createPoetrySdk(
- moduleBasePath: Path,
+ basePath: Path,
existingSdks: List,
pythonBinaryPath: PathHolder.Eel,
): PyResult = createSdk(
pythonBinaryPath = pythonBinaryPath,
existingSdks = existingSdks,
- associatedProjectPath = moduleBasePath.toString(),
- suggestedSdkName = suggestedSdkName(moduleBasePath),
- sdkAdditionalData = PyPoetrySdkAdditionalData(moduleBasePath)
+ associatedProjectPath = basePath.toString(),
+ suggestedSdkName = suggestedSdkName(basePath),
+ sdkAdditionalData = PyPoetrySdkAdditionalData(basePath)
)
internal val Sdk.isPoetry: Boolean
@@ -66,16 +66,6 @@ internal val Sdk.isPoetry: Boolean
return getOrCreateAdditionalData() is PyPoetrySdkAdditionalData
}
-internal fun sdkHomes(sdks: List): Set {
- return sdks.mapNotNull { it.homePath }.toSet()
-}
-
-internal fun allModules(project: Project?): List {
- return project?.let {
- ModuleUtil.getModulesOfType(it, PythonModuleTypeBase.getInstance())
- }?.sortedBy { it.name } ?: emptyList()
-}
-
private suspend fun setUpPoetry(moduleBasePath: Path, basePythonBinaryPath: PythonBinary?, installPackages: Boolean): PyResult {
val init = PyProjectToml.findInRoot(moduleBasePath) == null
val pythonHomePath = setupPoetry(moduleBasePath, basePythonBinaryPath, installPackages, init).getOr { return it }
diff --git a/python/src/com/jetbrains/python/target/PythonLanguageRuntimeUI.kt b/python/src/com/jetbrains/python/target/PythonLanguageRuntimeUI.kt
index bb6ea201c46c..f1e37260e5c3 100644
--- a/python/src/com/jetbrains/python/target/PythonLanguageRuntimeUI.kt
+++ b/python/src/com/jetbrains/python/target/PythonLanguageRuntimeUI.kt
@@ -4,6 +4,7 @@ package com.jetbrains.python.target
import com.intellij.execution.target.CustomToolLanguageConfigurable
import com.intellij.execution.target.LanguageRuntimeType
import com.intellij.execution.target.TargetEnvironmentConfiguration
+import com.intellij.execution.target.getTargetType
import com.intellij.openapi.module.Module
import com.intellij.openapi.observable.properties.AtomicProperty
import com.intellij.openapi.options.BoundConfigurable
@@ -17,8 +18,8 @@ import com.intellij.platform.ide.progress.runWithModalProgressBlocking
import com.intellij.ui.dsl.builder.panel
import com.intellij.util.concurrency.annotations.RequiresEdt
import com.intellij.util.ui.launchOnShow
-import com.jetbrains.python.PyBundle
import com.jetbrains.python.PyBundle.message
+import com.jetbrains.python.TraceContext
import com.jetbrains.python.errorProcessing.ErrorSink
import com.jetbrains.python.errorProcessing.emit
import com.jetbrains.python.newProjectWizard.projectPath.ProjectPathFlows
@@ -47,10 +48,11 @@ class PythonLanguageRuntimeUI(
private val errorSink: ErrorSink = ShowingMessageErrorSync
override fun createPanel(): DialogPanel {
+ val targetEnvironmentConfiguration = targetSupplier.get()
val model = PythonLocalAddInterpreterModel(
ProjectPathFlows.create(Path.of(project.basePath!!)),
FileSystem.Target(
- targetEnvironmentConfiguration = targetSupplier.get(),
+ targetEnvironmentConfiguration = targetEnvironmentConfiguration,
pythonLanguageRuntimeConfiguration = config,
)
)
@@ -69,7 +71,13 @@ class PythonLanguageRuntimeUI(
minimumSize = Dimension(800, 400)
}
- dialogPanel.launchOnShow("PythonAddLocalInterpreterDialog launchOnShow") {
+ dialogPanel.launchOnShow(
+ debugName = "PythonLanguageRuntimeUI launchOnShow",
+ context = TraceContext(
+ title = message("tracecontext.add.remote.python.sdk.dialog", targetEnvironmentConfiguration.getTargetType().displayName),
+ parentTraceContext = null
+ )
+ ) {
supervisorScope {
model.initialize(this@supervisorScope)
mainPanel.onShown(this@supervisorScope)