mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-30 11:09:22 +07:00
Extract various classes to the shared modules, `ExecutablePython` now has `env` map as it can be used by conda. GitOrigin-RevId: eb45ea29f49132fa4f91c979f71453e6a2ade344
40 lines
2.0 KiB
Kotlin
40 lines
2.0 KiB
Kotlin
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
package com.intellij.python.community.execService.python
|
|
|
|
import com.intellij.python.community.execService.ExecOptions
|
|
import com.intellij.python.community.execService.ExecService
|
|
import com.intellij.python.community.execService.PyProcessListener
|
|
import com.intellij.python.community.execService.ZeroCodeStdoutTransformer
|
|
import com.intellij.python.community.execService.python.advancedApi.ExecutablePython
|
|
import com.intellij.python.community.execService.python.advancedApi.executeHelperAdvanced
|
|
import com.intellij.python.community.execService.python.advancedApi.validatePythonAndGetVersion
|
|
import com.jetbrains.python.PythonBinary
|
|
import com.jetbrains.python.errorProcessing.PyExecResult
|
|
import com.jetbrains.python.errorProcessing.PyResult
|
|
import com.jetbrains.python.psi.LanguageLevel
|
|
import org.jetbrains.annotations.ApiStatus
|
|
|
|
/**
|
|
* Execute [helper] on [python]. For remote eels, [helper] is copied (but only one file!).
|
|
* Returns `stdout`
|
|
*/
|
|
suspend fun ExecService.executeHelper(
|
|
python: PythonBinary,
|
|
helper: HelperName,
|
|
args: List<String> = emptyList(),
|
|
options: ExecOptions = ExecOptions(),
|
|
procListener: PyProcessListener? = null,
|
|
): PyExecResult<String> =
|
|
executeHelperAdvanced(ExecutablePython.vanillaExecutablePython(python), helper, args, options, procListener, ZeroCodeStdoutTransformer)
|
|
|
|
/**
|
|
* Ensures that this python is executable and returns its version. Error if python is broken.
|
|
*
|
|
* Some pythons might be broken: they may be executable, even return a version, but still fail to execute it.
|
|
* As we need workable pythons, we validate it by executing
|
|
*/
|
|
@ApiStatus.Internal
|
|
suspend fun ExecService.validatePythonAndGetVersion(python: PythonBinary): PyResult<LanguageLevel> =
|
|
validatePythonAndGetVersion(ExecutablePython.vanillaExecutablePython(python))
|
|
|
|
suspend fun PythonBinary.validatePythonAndGetVersion(): PyResult<LanguageLevel> = ExecService().validatePythonAndGetVersion(this) |