Reset __PYVENV_LAUNCHER__ set by MacPorts that breaks site-packages in venvs (PY-18074)

Python 3.3+ interpreters installed via MacPorts set the system-wide
__PYVENV_LAUNCHER__ environment variable to point to the original
Python interpreter. That prevents any venvs from setting their correct
site-packages directories, because this variable is used in site.py
initialization logic for setting an alternative root for venvs.

This fix sets the __PYVENV_LAUNCHER__ to point to the correct location
of the project intepreter if this environment variable exists.
This commit is contained in:
Andrey Vlasovskikh
2016-08-03 14:55:34 +03:00
parent 3c8f350a73
commit 595f965be9
8 changed files with 39 additions and 12 deletions
@@ -46,9 +46,9 @@ import javax.swing.*;
import java.awt.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.jetbrains.python.sdk.PythonEnvUtil.setPythonIOEncoding;
import static com.jetbrains.python.sdk.PythonEnvUtil.setPythonUnbuffered;
import static com.jetbrains.python.sdk.PythonEnvUtil.*;
/**
* User : catherine
@@ -165,10 +165,14 @@ public class SphinxBaseCommand {
}
}
setPythonIOEncoding(cmd.getEnvironment(), "utf-8");
setPythonUnbuffered(cmd.getEnvironment());
cmd.getEnvironment().put("PYCHARM_EP_DIST", "Sphinx");
cmd.getEnvironment().put("PYCHARM_EP_NAME", "sphinx-quickstart");
final Map<String, String> env = cmd.getEnvironment();
setPythonIOEncoding(env, "utf-8");
setPythonUnbuffered(env);
if (sdkHomePath != null) {
resetHomePathChanges(sdkHomePath, env);
}
env.put("PYCHARM_EP_DIST", "Sphinx");
env.put("PYCHARM_EP_NAME", "sphinx-quickstart");
List<String> pathList = Lists.newArrayList(PythonCommandLineState.getAddedPaths(sdk));
pathList.addAll(PythonCommandLineState.collectPythonPath(module));