mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
PY-65295 Poetry installation
Fix poetry executable detection for the "Add new local interpreter" panel. There was a problem in `ModalityState`, which prevented updating `state.poetryExecutable` from EDT. Merge-request: IJ-MR-147485 Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com> (cherry picked from commit 43a807c20f8572bcf570121792269d6ee0c67acd) IJ-MR-147485 GitOrigin-RevId: fab1de5a2a55e62ff66790defb033b7745259dc5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f9f0322222
commit
23a2bfac5c
@@ -533,6 +533,7 @@ sdk.create.executable.directory.error=Path can't be a directory
|
||||
sdk.create.tooltip.browse=Browse\u2026
|
||||
sdk.create.custom.venv.install.fix.title=Install {0} {1}
|
||||
sdk.create.custom.venv.run.error.message= Error Running {0}
|
||||
sdk.create.custom.venv.progress.title.detect.executable=Detect executable
|
||||
|
||||
sdk.create.targets.local=Local Machine
|
||||
sdk.create.custom.virtualenv=Virtualenv
|
||||
|
||||
@@ -90,11 +90,14 @@ abstract class CustomNewEnvironmentCreator(private val name: String, model: Pyth
|
||||
* 4. Runs (pythonExecutable -m) pip install `package_name` --user
|
||||
* 5. Reruns `detectExecutable`
|
||||
*/
|
||||
@RequiresEdt
|
||||
private fun createInstallFix(): ActionLink {
|
||||
return ActionLink(message("sdk.create.custom.venv.install.fix.title", name, "via pip")) {
|
||||
PythonSdkFlavor.clearExecutablesCache()
|
||||
installExecutable()
|
||||
detectExecutable()
|
||||
runWithModalProgressBlocking(ModalTaskOwner.guess(), message("sdk.create.custom.venv.progress.title.detect.executable")) {
|
||||
detectExecutable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,5 +138,5 @@ abstract class CustomNewEnvironmentCreator(private val name: String, model: Pyth
|
||||
|
||||
protected abstract fun setupEnvSdk(project: Project?, module: Module?, baseSdks: List<Sdk>, projectPath: String, homePath: String?, installPackages: Boolean): Sdk?
|
||||
|
||||
internal abstract fun detectExecutable()
|
||||
internal abstract suspend fun detectExecutable()
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class PipEnvNewEnvironmentCreator(model: PythonMutableTargetAddInterpreterModel)
|
||||
override fun setupEnvSdk(project: Project?, module: Module?, baseSdks: List<Sdk>, projectPath: String, homePath: String?, installPackages: Boolean): Sdk? =
|
||||
setupPipEnvSdkUnderProgress(project, module, baseSdks, projectPath, homePath, installPackages)
|
||||
|
||||
override fun detectExecutable() {
|
||||
override suspend fun detectExecutable() {
|
||||
model.detectPipEnvExecutable()
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class PoetryNewEnvironmentCreator(model: PythonMutableTargetAddInterpreterModel,
|
||||
override fun setupEnvSdk(project: Project?, module: Module?, baseSdks: List<Sdk>, projectPath: String, homePath: String?, installPackages: Boolean): Sdk? =
|
||||
setupPoetrySdkUnderProgress(project, module, baseSdks, projectPath, homePath, installPackages)
|
||||
|
||||
override fun detectExecutable() {
|
||||
override suspend fun detectExecutable() {
|
||||
model.detectPoetryExecutable()
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package com.jetbrains.python.sdk.add.v2
|
||||
import com.intellij.execution.target.TargetEnvironmentConfiguration
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.diagnostic.getOrLogException
|
||||
import com.intellij.openapi.fileChooser.FileChooser
|
||||
import com.intellij.openapi.observable.properties.ObservableMutableProperty
|
||||
@@ -23,7 +24,7 @@ import com.jetbrains.python.sdk.flavors.PythonSdkFlavor
|
||||
import com.jetbrains.python.sdk.flavors.conda.PyCondaEnv
|
||||
import com.jetbrains.python.sdk.flavors.conda.PyCondaEnvIdentity
|
||||
import com.jetbrains.python.sdk.pipenv.pipEnvPath
|
||||
import com.jetbrains.python.sdk.poetry.getPoetryExecutable
|
||||
import com.jetbrains.python.sdk.poetry.poetryPath
|
||||
import com.jetbrains.python.util.ErrorSink
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
@@ -170,28 +171,30 @@ abstract class PythonMutableTargetAddInterpreterModel(params: PyInterpreterModel
|
||||
detectPipEnvExecutable()
|
||||
}
|
||||
|
||||
fun detectPoetryExecutable() {
|
||||
suspend fun detectPoetryExecutable() {
|
||||
// todo this is local case, fix for targets
|
||||
scope.launch(Dispatchers.IO) {
|
||||
val poetryExecutable = getPoetryExecutable()
|
||||
val savedPath = PropertiesComponent.getInstance().poetryPath
|
||||
if (savedPath != null) {
|
||||
state.poetryExecutable.set(savedPath)
|
||||
}
|
||||
else {
|
||||
val poetryExecutable = withContext(Dispatchers.IO) { com.jetbrains.python.sdk.poetry.detectPoetryExecutable() }
|
||||
withContext(Dispatchers.EDT) {
|
||||
poetryExecutable?.let { state.poetryExecutable.set(it.pathString) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun detectPipEnvExecutable() {
|
||||
suspend fun detectPipEnvExecutable() {
|
||||
// todo this is local case, fix for targets
|
||||
val savedPath = PropertiesComponent.getInstance().pipEnvPath
|
||||
if (savedPath != null) {
|
||||
state.pipenvExecutable.set(savedPath)
|
||||
}
|
||||
else {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
val detectedExecutable = com.jetbrains.python.sdk.pipenv.detectPipEnvExecutable()
|
||||
withContext(Dispatchers.EDT) {
|
||||
detectedExecutable?.let { state.pipenvExecutable.set(it.path) }
|
||||
}
|
||||
val detectedExecutable = withContext(Dispatchers.IO) { com.jetbrains.python.sdk.pipenv.detectPipEnvExecutable() }
|
||||
withContext(Dispatchers.EDT) {
|
||||
detectedExecutable?.let { state.pipenvExecutable.set(it.path) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user