Pass shell environment before obtaining virtualenv environment for script execution (PY-17816)

If an IDE is executed not terminal on macOS it doesn't get shell environment and this prevents getting the correct environment by virtualenv activation
This commit is contained in:
Dmitry Trofimov
2017-04-11 19:48:32 +02:00
parent 7fad69fc05
commit bf98ba3576
2 changed files with 29 additions and 5 deletions
@@ -67,6 +67,11 @@ class PyVirtualEnvReader(val virtualEnvSdkPath: String) : EnvironmentUtil.ShellE
}
}
override fun dumpProcessEnvToFile(command: MutableList<String>, envFile: File, lineSeparator: String?): MutableMap<String, String> {
// pass shell environment for correct virtualenv environment setup (virtualenv expects to be executed from the terminal)
return runProcessAndReadEnvs(command, null, EnvironmentUtil.getEnvironmentMap(), envFile, lineSeparator)
}
private fun readVirtualEnvOnWindows(activate: Pair<String, String?>): MutableMap<String, String> {
val activateFile = FileUtil.createTempFile("pycharm-virualenv-activate.", ".bat", false)
val envFile = FileUtil.createTempFile("pycharm-virualenv-envs.", ".tmp", false)