mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-91416 show missing SDK notification for WSL uv projects
Skip uv SDK configuration when the associated module has no resolvable base directory. This avoids missing-working-directory failures and preserves the normal missing-SDK notification path. (cherry picked from commit 5aa7b369b7b658e311c47a616b332f2b40d8392a) IJ-MR-216899 GitOrigin-RevId: 77878855d244c1fb6446d025edc8a6ddb744f147
This commit is contained in:
committed by
intellij-monorepo-bot
parent
499687b73d
commit
3b6d62e781
@@ -19,7 +19,7 @@ internal class PyUvBaseSdkConfiguration : PyProjectSdkConfigurationExtension {
|
||||
|
||||
override suspend fun checkEnvironmentAndPrepareSdkCreator(module: Module, venvsInModule: List<PythonBinary>): CreateSdkInfo? =
|
||||
prepareSdkCreator(
|
||||
{ checkManageableUvEnvBase(venvsInModule) }
|
||||
{ checkManageableUvEnvBase(module, toolId, venvsInModule) }
|
||||
) { envExists -> { createUvSdk(module, toolId, venvsInModule, envExists) } }
|
||||
|
||||
override fun asPyProjectTomlSdkConfigurationExtension(): PyProjectTomlConfigurationExtension? = null
|
||||
|
||||
@@ -34,7 +34,7 @@ internal class PyUvSdkConfiguration : PyProjectTomlConfigurationExtension {
|
||||
venvsInModule: List<PythonBinary>,
|
||||
tomlCheckedByWorkspaceTools: Boolean
|
||||
): EnvCheckerResult {
|
||||
val baseCheckResult = checkManageableUvEnvBase(venvsInModule)
|
||||
val baseCheckResult = checkManageableUvEnvBase(module, toolId, venvsInModule)
|
||||
return when (baseCheckResult) {
|
||||
is EnvCheckerResult.EnvFound, is EnvCheckerResult.SuggestToolInstallation -> baseCheckResult
|
||||
is EnvCheckerResult.EnvNotFound -> if (tomlCheckedByWorkspaceTools || findUvLock(module) != null) baseCheckResult else EnvCheckerResult.CannotConfigure
|
||||
|
||||
@@ -8,32 +8,35 @@ import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.python.community.common.tools.ToolId
|
||||
import com.jetbrains.python.PyBundle
|
||||
import com.jetbrains.python.PythonBinary
|
||||
import com.jetbrains.python.errorProcessing.ErrorSink
|
||||
import com.jetbrains.python.errorProcessing.PyResult
|
||||
import com.jetbrains.python.errorProcessing.withProject
|
||||
import com.jetbrains.python.onSuccess
|
||||
import com.jetbrains.python.sdk.PythonEnvironment
|
||||
import com.jetbrains.python.sdk.baseDir
|
||||
import com.jetbrains.python.sdk.configuration.EnvCheckerResult
|
||||
import com.jetbrains.python.sdk.configuration.findEnvOrNull
|
||||
import com.jetbrains.python.sdk.configuration.getSdkAssociatedModule
|
||||
import com.jetbrains.python.sdk.PythonEnvironment
|
||||
import com.jetbrains.python.sdk.detectPythonEnvironment
|
||||
import com.jetbrains.python.sdk.setAssociationToModule
|
||||
import com.jetbrains.python.sdk.uv.impl.getUvExecutableLocal
|
||||
import com.jetbrains.python.sdk.uv.setupExistingEnvAndSdk
|
||||
import com.jetbrains.python.sdk.uv.setupNewUvSdkAndEnv
|
||||
import com.jetbrains.python.errorProcessing.ErrorSink
|
||||
import com.jetbrains.python.errorProcessing.withProject
|
||||
import com.jetbrains.python.venvReader.tryResolvePath
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.nio.file.Path
|
||||
import kotlin.collections.contains
|
||||
|
||||
private val logger = fileLogger()
|
||||
|
||||
internal suspend fun checkManageableUvEnvBase(
|
||||
module: Module,
|
||||
toolId: ToolId,
|
||||
venvsInModule: List<PythonBinary>,
|
||||
): EnvCheckerResult {
|
||||
getUvExecutableLocal() ?: return EnvCheckerResult.CannotConfigure
|
||||
val sdkAssociatedModule = module.getSdkAssociatedModule(toolId)
|
||||
tryResolvePath(sdkAssociatedModule.baseDir?.path) ?: return EnvCheckerResult.CannotConfigure
|
||||
val intentionName = PyBundle.message("sdk.set.up.uv.environment")
|
||||
val envFound = getUvEnv(venvsInModule)?.findEnvOrNull(intentionName)
|
||||
return envFound ?: EnvCheckerResult.EnvNotFound(intentionName)
|
||||
@@ -71,4 +74,4 @@ private fun getUvEnv(venvsInModule: List<PythonBinary>): PythonBinary? = venvsIn
|
||||
|
||||
internal fun PythonBinary.isUvEnv(): Boolean {
|
||||
return detectPythonEnvironment().successOrNull?.let { it is PythonEnvironment.Venv && "uv" in it.config } == true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user