mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert "Python Env Tests: support python.exe from Windows Apps in PYTHON_FOR_TESTS"
This reverts commit dc3c04ab43749a1c02285ccdc4deab01f49b13c1. (cherry picked from commit 93aaf56d801631313443cf9f04b58f6da1cd964e) IJ-CR-178048 GitOrigin-RevId: f44adec30cb46f26f8717a9bb4b8174766e8fea0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
16e7c47b73
commit
d7e0b918d7
+8
-41
@@ -3,24 +3,19 @@ package com.intellij.python.community.testFramework.testEnv
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
|
||||
import com.jetbrains.python.PythonBinary
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor
|
||||
import com.jetbrains.python.venvReader.VirtualEnvReader
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.nio.file.FileSystemException
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.Result.Companion.failure
|
||||
import kotlin.io.path.listDirectoryEntries
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.pathString
|
||||
import kotlin.io.path.readAttributes
|
||||
|
||||
/**
|
||||
* Gradle script installs two types of python: conda and vanilla. Env could be obtained by [createSdkClosableEnv] which also provides closable
|
||||
@@ -72,44 +67,16 @@ abstract class PythonType<T : Any>(private val tag: @NonNls String) {
|
||||
""".trimIndent())
|
||||
}
|
||||
val pythonPath = Path.of(pythonStr)
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
var pythonBinary: Path? = null
|
||||
val err = IllegalStateException("$PYTHON_FOR_TESTS env var points to something that is not a python: $pythonPath")
|
||||
|
||||
try {
|
||||
val attrs = pythonPath.readAttributes<BasicFileAttributes>()
|
||||
|
||||
pythonBinary = if (attrs.isDirectory) {
|
||||
VirtualEnvReader.Instance.findPythonInPythonRoot(pythonPath)
|
||||
}
|
||||
else {
|
||||
pythonPath
|
||||
}
|
||||
}
|
||||
catch (err2: FileSystemException) {
|
||||
err.initCause(err2)
|
||||
|
||||
// Handling a possible reparse point from WindowsApps.
|
||||
if (SystemInfo.isWindows && err2.javaClass == FileSystemException::class.java) {
|
||||
try {
|
||||
if (pythonPath in pythonPath.parent!!.listDirectoryEntries()) {
|
||||
pythonBinary = pythonPath
|
||||
}
|
||||
}
|
||||
catch (err3: FileSystemException) {
|
||||
err.addSuppressed(err3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pythonBinary?.parent ?: throw err
|
||||
}
|
||||
val pythonBinary = when {
|
||||
pythonPath.isDirectory() -> VirtualEnvReader.Instance.findPythonInPythonRoot(pythonPath)
|
||||
pythonPath.exists() -> pythonPath
|
||||
else -> null
|
||||
} ?: error("$PYTHON_FOR_TESTS env var points to something that is not a python: $pythonPath")
|
||||
pythonBinary.parent
|
||||
}
|
||||
else {
|
||||
null
|
||||
}
|
||||
|
||||
if (customPythonDir != null) {
|
||||
pythons.add(customPythonDir)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user