if (project == null) { //Ok, we could not find it out
throw Log.log("Could not get project for configuration: " + conf);
}
// We need the project to find out the default interpreter from the InterpreterManager.
IPythonNature pythonNature = PythonNature.getPythonNature(project);
if (pythonNature == null) {
CoreException e = Log.log("No python nature for project: " + project.getName());
throw e;
}
//now, go on configuring other things
this.configuration = conf;
this.run = run;
isDebug = mode.equals(ILaunchManager.DEBUG_MODE);
isInteractive = mode.equals("interactive");
resource = getLocation(conf, pythonNature);
arguments = getArguments(conf, makeArgumentsVariableSubstitution);
IPath workingPath = getWorkingDirectory(conf, pythonNature);
workingDirectory = workingPath == null ? null : workingPath.toFile();
acceptTimeout = PydevPrefs.getPreferences().getInt(PydevEditorPrefs.CONNECT_TIMEOUT);
interpreterLocation = getInterpreterLocation(conf, pythonNature, this.getRelatedInterpreterManager());
interpreter = getInterpreter(interpreterLocation, conf, pythonNature);
//make the environment
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
envp = launchManager.getEnvironment(conf);
IInterpreterManager manager;
if (isJython()) {
manager = PydevPlugin.getJythonInterpreterManager();
} else if (isIronpython()) {
manager = PydevPlugin.getIronpythonInterpreterManager();
} else {
manager = PydevPlugin.getPythonInterpreterManager();
}
boolean win32 = PlatformUtils.isWindowsPlatform();
if (envp == null) {
//ok, the user has done nothing to the environment, just get all the default environment which has the pythonpath in it
envp = SimpleRunner.getEnvironment(pythonNature, interpreterLocation, manager);
} else {
//ok, the user has done something to configure it, so, just add the pythonpath to the
//current env (if he still didn't do so)
Map envMap = conf.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map) null);
String pythonpath = SimpleRunner.makePythonPathEnvString(pythonNature, interpreterLocation, manager);
updateVar(pythonNature, manager, win32, envMap, "PYTHONPATH", pythonpath);
if (isJython()) {
//Also update the classpath env variable.
updateVar(pythonNature, manager, win32, envMap, "CLASSPATH", pythonpath);
// And the jythonpath env variable
updateVar(pythonNature, manager, win32, envMap, "JYTHONPATH", pythonpath);
} else if (isIronpython()) {
//Also update the ironpythonpath env variable.
updateVar(pythonNature, manager, win32, envMap, "IRONPYTHONPATH", pythonpath);
}
//And we also must get the environment variables specified in the interpreter manager.
envp = interpreterLocation.updateEnv(envp, envMap.keySet());
}
String settingsModule = null;
Map<String, String> variableSubstitution = null;
final String djangoSettingsKey = "DJANGO_SETTINGS_MODULE";
String djangoSettingsEnvEntry = null;
try {
variableSubstitution = pythonNature.getPythonPathNature().getVariableSubstitution();
settingsModule = variableSubstitution.get(djangoSettingsKey);
if (settingsModule != null) {
if (settingsModule.trim().length() > 0) {
djangoSettingsEnvEntry = djangoSettingsKey + "=" + settingsModule.trim();
}