diff --git a/python/pluginResources/intellij.python.community.impl.xml b/python/pluginResources/intellij.python.community.impl.xml
index 59aaea2e9d4d..85bf937b61af 100644
--- a/python/pluginResources/intellij.python.community.impl.xml
+++ b/python/pluginResources/intellij.python.community.impl.xml
@@ -168,8 +168,8 @@
-
-
+
+
diff --git a/python/src/com/jetbrains/python/run/PythonCommandLineState.java b/python/src/com/jetbrains/python/run/PythonCommandLineState.java
index 19cb22c91bbc..1315deaa68c7 100644
--- a/python/src/com/jetbrains/python/run/PythonCommandLineState.java
+++ b/python/src/com/jetbrains/python/run/PythonCommandLineState.java
@@ -650,20 +650,11 @@ public abstract class PythonCommandLineState extends CommandLineState {
*/
protected static void initEnvironment(Project project,
SdkAdditionalData data,
- GeneralCommandLine commandLine,
- PythonRunParams runParams,
+ @NotNull GeneralCommandLine commandLine,
+ @NotNull PythonRunParams runParams,
boolean isDebug) {
- Map env = Maps.newHashMap();
-
+ final Map env = prepareEnv(project, runParams, true);
setupEncodingEnvs(env, commandLine.getCharset());
-
- if (runParams.getEnvs() != null) {
- env.putAll(runParams.getEnvs());
- }
- addCommonEnvironmentVariables(getInterpreterPath(project, runParams), env, true);
-
- setupVirtualEnvVariables(runParams, env, runParams.getSdkHome());
-
commandLine.getEnvironment().clear();
commandLine.getEnvironment().putAll(env);
commandLine.withParentEnvironmentType(runParams.isPassParentEnvs() ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);
@@ -695,19 +686,13 @@ public abstract class PythonCommandLineState extends CommandLineState {
boolean isDebug,
@NotNull HelpersAwareTargetEnvironmentRequest helpersAwareTargetRequest,
@Nullable Sdk sdk) {
- Map env = Maps.newHashMap();
- var envParameters = configureEnvsFromFiles(runParams, true);
- env.putAll(envParameters);
- if (runParams.getEnvs() != null) {
- env.putAll(runParams.getEnvs());
- }
boolean addPyCharmHosted = true;
if (sdk != null && !CondaPythonExecKt.getUsePythonForLocalConda()) {
addPyCharmHosted = PySdkExtKt.getOrCreateAdditionalData(sdk).getFlavor().providePyCharmHosted();
}
- addCommonEnvironmentVariables(getInterpreterPath(project, runParams), env, addPyCharmHosted);
+ final Map env = prepareEnv(project, runParams, addPyCharmHosted);
- setupVirtualEnvVariables(runParams, env, runParams.getSdkHome());
+ setupEncodingEnvs(commandLine, commandLine.getCharset());
// Carefully patch environment variables
Map> map =
@@ -715,8 +700,6 @@ public abstract class PythonCommandLineState extends CommandLineState {
TargetEnvironmentRequest targetEnvironmentRequest = helpersAwareTargetRequest.getTargetEnvironmentRequest();
PythonScripts.extendEnvs(commandLine, map, targetEnvironmentRequest.getTargetPlatform());
- setupEncodingEnvs(commandLine, commandLine.getCharset());
-
buildPythonPath(project, commandLine, runParams, pathMapper, isDebug, targetEnvironmentRequest);
for (PythonCommandLineTargetEnvironmentProvider envProvider : PythonCommandLineTargetEnvironmentProvider.EP_NAME.getExtensionList()) {
@@ -724,6 +707,20 @@ public abstract class PythonCommandLineState extends CommandLineState {
}
}
+ private static Map prepareEnv(@NotNull Project project,
+ @NotNull PythonRunParams runParams,
+ boolean addPyCharmHosted) {
+ Map env = Maps.newHashMap();
+ env.putAll(configureEnvsFromFiles(runParams, true));
+ if (runParams.getEnvs() != null) {
+ env.putAll(runParams.getEnvs());
+ }
+ addCommonEnvironmentVariables(getInterpreterPath(project, runParams), env, addPyCharmHosted);
+
+ setupVirtualEnvVariables(runParams, env, runParams.getSdkHome());
+ return env;
+ }
+
private static void setupVirtualEnvVariables(PythonRunParams myConfig, Map env, String sdkHome) {
Sdk sdk = PythonSdkUtil.findSdkByPath(sdkHome);
if (sdk != null &&