mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
PY-22469: Activate Python venv in terminal when Powershell used as shell
(cherry picked from commit 8b1071f8fdeb306213e43e8c971ebffb2077aac3) IJ-CR-20759 GitOrigin-RevId: 8a65ea59b40d5d985b9fb5a7910201d52b5fef04
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d33902fd9b
commit
a60c2cd8d6
@@ -9,11 +9,14 @@ import com.intellij.openapi.options.UnnamedConfigurable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.util.io.exists
|
||||
import com.jetbrains.python.run.findActivateScript
|
||||
import org.jetbrains.plugins.terminal.LocalTerminalCustomizer
|
||||
import org.jetbrains.plugins.terminal.TerminalOptionsProvider
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import javax.swing.JCheckBox
|
||||
import kotlin.io.path.pathString
|
||||
|
||||
class PyVirtualEnvTerminalCustomizer : LocalTerminalCustomizer() {
|
||||
override fun customizeCommandAndEnvironment(project: Project,
|
||||
@@ -29,6 +32,12 @@ class PyVirtualEnvTerminalCustomizer : LocalTerminalCustomizer() {
|
||||
|
||||
if (path != null && command.isNotEmpty()) {
|
||||
val shellPath = command[0]
|
||||
|
||||
if (shellPath == "powershell.exe") {
|
||||
val powerShellActivator = Path.of(path).parent?.resolve("activate.ps1") ?: return command
|
||||
return if (powerShellActivator.exists()) arrayOf("powershell.exe", "-NoExit", "-File", powerShellActivator.pathString) else command
|
||||
}
|
||||
|
||||
if (isShellIntegrationAvailable(shellPath)) { //fish shell works only for virtualenv and not for conda
|
||||
//for bash we pass activate script to jediterm shell integration (see jediterm-bash.in) to source it there
|
||||
//TODO: fix conda for fish
|
||||
|
||||
Reference in New Issue
Block a user