From bc09d9cd01300588fc5993bc8d52255f3c5f19d8 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 2 Apr 2025 02:26:56 +0200 Subject: [PATCH] Python tests: store a path to conda in `PyCondaPackageService`. While one should use a conda path from `PyCondaFlavorData`, some legacy code still depends on this service. This service does a good job trying to find conda on a user PC, but obviously fails in test as conda is installed in a usual location. We store a conda path in this service to make tests work GitOrigin-RevId: d8e1d08b268ae5259e7050c5c9bb8cc8184e3751 --- .../python/community/testFramework/testEnv/conda/TypeConda.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/setup-test-environment/conda/src/com/intellij/python/community/testFramework/testEnv/conda/TypeConda.kt b/python/setup-test-environment/conda/src/com/intellij/python/community/testFramework/testEnv/conda/TypeConda.kt index f8f7db6225f2..3ee02bf7db6f 100644 --- a/python/setup-test-environment/conda/src/com/intellij/python/community/testFramework/testEnv/conda/TypeConda.kt +++ b/python/setup-test-environment/conda/src/com/intellij/python/community/testFramework/testEnv/conda/TypeConda.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.projectRoots.Sdk import com.intellij.python.community.testFramework.testEnv.PythonType import com.jetbrains.python.PythonBinary +import com.jetbrains.python.packaging.PyCondaPackageService import com.jetbrains.python.packaging.findCondaExecutableRelativeToEnv import com.jetbrains.python.sdk.conda.TargetEnvironmentRequestCommandExecutor import com.jetbrains.python.sdk.flavors.conda.PyCondaEnv @@ -14,6 +15,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import org.jetbrains.annotations.ApiStatus.Internal import java.nio.file.Path +import kotlin.io.path.pathString @Internal data object TypeConda : PythonType("conda") { @@ -23,6 +25,8 @@ data object TypeConda : PythonType("conda") { override suspend fun pythonPathToEnvironment(pythonBinary: PythonBinary, envDir: Path): Pair { // First, find python binary, then calculate conda from it as env stores "conda" as a regular env val condaPath = findCondaExecutableRelativeToEnv(pythonBinary) ?: error("Conda root $pythonBinary doesn't have conda binary") + // Save a path to conda because some legacy code might use it instead of a full conda path from additional data + PyCondaPackageService.onCondaEnvCreated(condaPath.pathString) // We'll remove then on close val condaEnvsBeforeTest = getCondaNames(condaPath)