mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
Python: extract python-specific extensions from exec service to simplify API and make it extendable for intepreters.
Use `ExecService` `api.kt` to exec any binary and extensions from `execService.python/api.kt` for python-specific things (i.e helpers) GitOrigin-RevId: bb217798a9d1ee886c4b12220ec1f66a5ef08336
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fd2ad62299
commit
2e14347844
@@ -3,7 +3,6 @@ package com.intellij.python.hatch.runtime
|
||||
import com.intellij.platform.eel.EelApi
|
||||
import com.intellij.platform.eel.provider.localEel
|
||||
import com.intellij.python.community.execService.*
|
||||
import com.intellij.python.community.execService.WhatToExec.Binary
|
||||
import com.intellij.python.hatch.*
|
||||
import com.intellij.python.hatch.cli.HatchCli
|
||||
import com.jetbrains.python.PythonBinary
|
||||
@@ -17,7 +16,7 @@ import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.isExecutable
|
||||
|
||||
class HatchRuntime(
|
||||
val hatchBinary: Binary,
|
||||
val hatchBinary: Path,
|
||||
val execOptions: ExecOptions,
|
||||
private val execService: ExecService = ExecService(),
|
||||
) {
|
||||
@@ -60,12 +59,12 @@ class HatchRuntime(
|
||||
}
|
||||
|
||||
internal suspend fun <T> executeInteractive(vararg arguments: String, processSemiInteractiveFun: ProcessSemiInteractiveFun<T>): PyExecResult<T> {
|
||||
return execService.execute(hatchBinary, arguments.toList(), execOptions, processSemiInteractiveHandler(code = processSemiInteractiveFun))
|
||||
return execService.executeAdvanced(hatchBinary, { addArgs(*arguments) }, execOptions, processSemiInteractiveHandler(code = processSemiInteractiveFun))
|
||||
}
|
||||
|
||||
internal suspend fun resolvePythonVirtualEnvironment(pythonHomePath: PythonHomePath): PyResult<PythonVirtualEnvironment> {
|
||||
val pythonVersion = pythonHomePath.takeIf { it.isDirectory() }?.resolvePythonBinary()?.let { pythonBinaryPath ->
|
||||
execService.execGetStdout(Binary(pythonBinaryPath), listOf("--version")).getOr { return it }.trim()
|
||||
execService.execGetStdout(pythonBinaryPath, listOf("--version")).getOr { return it }.trim()
|
||||
}
|
||||
val pythonVirtualEnvironment = when {
|
||||
pythonVersion == null -> PythonVirtualEnvironment.NotExisting(pythonHomePath)
|
||||
@@ -99,7 +98,7 @@ suspend fun createHatchRuntime(
|
||||
val actualEnvVars = defaultVariables + envVars
|
||||
|
||||
val runtime = HatchRuntime(
|
||||
hatchBinary = Binary(actualHatchExecutable),
|
||||
hatchBinary = actualHatchExecutable,
|
||||
execOptions = ExecOptions(
|
||||
env = actualEnvVars,
|
||||
workingDirectory = workingDirectoryPath
|
||||
|
||||
Reference in New Issue
Block a user