Re: [Pydev-code] Programmatically set python interpreter and createproject
Brought to you by:
fabioz
From: Doubleday, D. <ddo...@vo...> - 2011-02-17 15:40:32
|
I don't know if this will help, but this is what we do to create a new interpreter programmatically. Prior to this call, we have gotten the list of InterpreterInfo from Pydev, added a new InterpreterInfo object for our new interpreter to the list, and then called this method. private static void setInterpreters(List<IInterpreterInfo> validInterpreters, IProgressMonitor monitor) { // 1. stop any running interpreters List<IInterpreterInfo> interpreterList = getInstalledInterpreters(); // Restoring the interpreters and stopping the server shell for (IInterpreterInfo interpreter : interpreterList) { AbstractShell.stopServerShell( interpreter, AbstractShell.COMPLETION_SHELL); } // 2. set new interpreter info PydevPlugin.getPythonInterpreterManager(true).setInfos( validInterpreters); // 3. configure new interpreters PydevPlugin.getPythonInterpreterManager(true) .restorePythopathForInterpreters(monitor, null); // 4. persist interpreter info PydevPlugin.getPythonInterpreterManager(true) .saveInterpretersInfoModulesManager(); // 5. get persist string and set it back to manager String persistInfo = PydevPlugin.getPythonInterpreterManager(true) .getStringToPersist( validInterpreters .toArray(new IInterpreterInfo[validInterpreters.size()])); PydevPlugin.getPythonInterpreterManager(true).setPersistedString( persistInfo); // 6. Reloading the Interpreter page for python PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode node = pm .find("org.python.pydev.prefs/" //$NON-NLS-1$ + "org.python.pydev.ui.pythonpathconf.interpreterPreferencesPagePython"); //$NON-NLS-1$ WorkbenchPreferenceNode wpNode = (WorkbenchPreferenceNode) node; wpNode.setPage(null); } -----Original Message----- From: Thomas Johnsson [mailto:th...@sk...] Sent: Thursday, February 17, 2011 5:09 AM To: pyd...@li... Subject: [Pydev-code] Programmatically set python interpreter and createproject Hi, I'm trying to programmatically, in a new workspace, - set python interpreter whose details are known, - create a pydev project, using the interpreter. I've tried things along the lines of String interpreterpersistedstring = "Name:dwspython:EndName:Version2.6......&&&&&"; // as previously obtained from a getPersistedString IInterpreterManager im = PydevPlugin.getPythonInterpreterManager(); im.setPersistedString(interpreterpersistedstring); and then create the project using PyStructureConfigHelpers.createPydevProject(projectname, projectLocationPath, null, // IProject[] references monitor, IPythonNature.PYTHON_VERSION_2_6, "dwspython", null, null, null); The immediate problem with this is that the interpreter set with setPersistedString is not known by createPydevProject also confirmed by im.hasInfoOnInterpreter("dwspython") returning false. A call im.saveInterpretersInfoModulesManager(); does not help either it seems. Any help and hints on how to do this properly is greatly appreciated! Thanks, -- Thomas Johnsson ------------------------------------------------------------------------ ------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ pydev-code mailing list pyd...@li... https://lists.sourceforge.net/lists/listinfo/pydev-code |