// 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 = emptyList(), options: ExecOptions = ExecOptions(), procListener: PyProcessListener? = null, ): PyExecResult = 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 = validatePythonAndGetVersion(ExecutablePython.vanillaExecutablePython(python)) suspend fun PythonBinary.validatePythonAndGetVersion(): PyResult = ExecService().validatePythonAndGetVersion(this)