Thread: [Pydev-code] Python interpreter (was: Introduction to PyDev list)
Brought to you by:
fabioz
From: Raul F. H. <ra...@em...> - 2008-12-05 20:18:24
|
Hi, On Thu, Dec 4, 2008 at 10:29 PM, Fabio Zadrozny <fa...@gm...> wrote: > > For maemo applications, we need to run commands on Scratchbox, using the > > command "/scratchbox/login <command>". In addiction, we can execute this > > command also on a remote environment throught ssh (ssh user@X.X.X.X > > python2.5 ...) > > Given that, how are you planning to make Pydev run that interpreter > from within eclipse? Don't you feel it's easier to create an > executable that runs things as if it was a local version of python.exe > and gathers things from the actual remote interpreter? (making a > custom interpreter won't actually solve the problem of how to execute > things remotely... the execution part is pretty much separated from > the interpreter configuration -- not that it can't be done, but I'm > not sure it's worth it). > Commands are being executed on remote (or local, but "sandboxed" environments) properly and the Python interpreter is not used to run these commands. 1) Why do we need extension points to define our own Python interpreter MANAGER? on class *org.python.pydev.ui.interpreters.PythonInterpreterManager*, the following method is used to obtain information about a certain Python interpreter. public static Tuple<InterpreterInfo,String> doCreateInterpreterInfo(String executable, IProgressMonitor monitor) throws CoreException { .... *File script = PydevPlugin.getScriptWithinPySrc("interpreterInfo.py");** Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutputWithInterpreter(executable, REF.getFileAbsolutePath(script), null, null, null, monitor);* InterpreterInfo info = createInfoFromOutput(monitor, outTup); .... } The method SimplePythonRunner()#runAndGetOutputWithInterpreter runs the script <interpreterInfo.py>, which gets the information about the Python interpreter that is used to execute the script! For example, </usr/bin/python2.5 interpreterInfo.py> gets the information about /usr/bin/python2.5. If I want to get information about an interpreter that is located on a sandboxed environment (for example, Scratchbox), I need to execute this command in a different format: </scratchbox/login /usr/bin/python2.5 interpreterInfo.py>. The point is that PythonInterpreterManager does not give us option to change the execution command line to execute the script <interpreterInfo.py>. We can also extend this problem to remote python interpreters. For example, maybe we need to define another script to get information about the remote interpreter (/usr/bin/python2.5 obtainRemoteInterpreterInfo.py>. In this case, the local interpreter is used just to start the script. We need extension points to create PythonInterpreterManagers so we can define how the information about a certain interpreter can be obtained by invoking the method AbstractInterpreterManager#doCreateInterpreterInfo(). Currently, there're only two PythonIntepreterManagers (python and jython), which are private attributes of PydevPlugin and defined on PydevPlugin#start. I checked how this would affect current pydev core. In fact, we just need to change the PydevPlugin: the python interpreters managers wouldn't be defined there anymore, but on a PythonInterpreterManagerRegistry class which gets the PythonInterpreterManagers from .xml files (defined as extension points) and some more a couple of classes that access the python interpreters managers by using PydevPlugin#getPythonInterpreterManager() or PydevPlugin#getJythonInterpreterManager(). []'s --Raul |
From: Fabio Z. <fa...@gm...> - 2008-12-08 00:28:07
|
> 1) Why do we need extension points to define our own Python interpreter > MANAGER? > > ... > > I checked how this would affect current pydev core. In fact, we just need to > change the PydevPlugin: the python interpreters managers wouldn't be defined > there anymore, but on a PythonInterpreterManagerRegistry class which gets > the PythonInterpreterManagers from .xml files (defined as extension points) > and some more a couple of classes that access the python interpreters > managers by using PydevPlugin#getPythonInterpreterManager() or > PydevPlugin#getJythonInterpreterManager(). Do you think you can create/send a patch for that? As you know your problem better than me, you're probably better suited to solve that (the only thing is that you should also provide a unit-test for the feature implemented, as the default version probably won't use it -- otherwise it may end up being removed or broken for some reason). See http://pydev.sourceforge.net/developers.html for details on how to create the patch. Cheers, Fabio |