Sunday, June 28, 2009

Testing on Pydev 1.4.7 & IronPython

Pydev 1.4.7 is now ready to be tested for a new release (watch for the nightly build with svn version 2834 -- http://pydev.blogspot.com/2009/02/pydev-nightly-builds.html )

One of the major features in this release is the IronPython integration. Note that it requires IronPython 2.6 (earlier versions are not supported because of the lack of sys._getframe()).

In that integration, code-completion should be working for the .NET libraries and other dlls. For the .NET libraries, just make sure that the library you're using is listed in the forced builtins ( http://fabioz.com/pydev/manual_101_interpreter.html ) -- I believe all libraries should be there already, but it could be that some default library is missing.

To use code-completion for other libraries, the code must be compiled as a dll (because Pydev does not recognize C# nor VB) and that dll must have the exact same name of the namespace it contains (e.g.: if you want to do "import iTextSharp", the dll must be named iTextSharp.dll -- the case of the file important there) and the folder containing that dll must be added as a source folder (or external source folder) -- which is the same thing for python compiled extensions.

Most features should be working fine with IronPython, with the most notable exception being that the debugger is not supported (that's because in this version, IronPython still doesn't provide sys.settrace(), so, there's no API to work on for python debugging).

Other niceties were also added in this release:

  • Ctrl+F9 (which was previously a run as jython) now executes a run as unit-test based on the project type, providing an interface where the user can filter which tests should be run, and F9 which was a run-as python is now a run as current project type -- so, it works for python, jython and ironpython projects).

  • Pydev Extensions context-insensitive completions are shown for any token which cannot be determined by the type inference engine (previously it did that only for method parameters) -- and the number of chars for showing those completions can be customized (by default, 2 chars are required).

16 comments:

Damien Lebrun said...

Is it compatible with Eclipse 3.5?

Fabio Zadrozny said...

Yes.

Anonymous said...

I've done everything as instructed and the code completion does not work with message:
Error connecting to python process (Name:IronPython:EndName:Version2.6...then a bunch of directories)

I am using Eclipse 3.5 and IronPython 2.6 in Vista.

Any help greatly appreciated.

Anonymous said...

Same message as above, but with the end of the error message:

Err output:
Traceback (most recent call last):

File "C:\eclipse\plugins\org.python.pydev_1.4.7.2843
\PySrc\pycompletionserver.py", line 32, in C:\eclipse\plugins\org.
python.pydev_1.4.7.2843\PySrc\pycompletionserver.py

File "C:\eclipse\plugins\org.python.pydev_1.4.7.2843
\PySrc\importsTipper.py", line 4, in C:\eclipse\plugins\org.python.
pydev_1.4.7.2843\PySrc\importsTipper.py

File "C:\Program Files\IronPython 2.6\Lib\inspect.py", line 950,
in C:\Program Files\IronPython 2.6\Lib\inspect.py

AttributeError: 'module' object has no attribute '_getframe'
At: at org.python.pydev.editor.codecompletion.shell.AbstractShell.
startIt(AbstractShell.java:467)

Fabio Zadrozny said...

The usual problem if it cannot connect to the spawned shell is that you have an active firewall that's blocking the communication (which would block the communication in that case).

Fabio Zadrozny said...

Are you using 2.6 beta 1? (that's the version that has sys._getframe())

Anonymous said...

Thanks for helping me out...yes, here is the version i am using:
IronPython 2.6 Beta 1 (2.6.0.10) on .NET 2.0.50727.3074

I have VirusScan Enterprise from McAfee...and i have some control over the ports, etc...can you give me a clue of what should i be looking to allow...thanks!

Fabio Zadrozny said...

Another doubt, is -X:Frames in the 'vm arguments for internal shell' at window > preferences > pydev > interpreter - Iron Python?

(pydev should include that automatically at that place -- otherwise sys._getframe() won't actually be available)

For the firewall, I believe you have to enable access to eclipse and ipy (the ports are actually random)

Anonymous said...

Fabio, i really appreciate your help...how frustrating though...i confirmed that -X:Frames is set as required and I unblocked the eclipse and ipy.exe program in the windows firewall...i re-started eclipse and still no cigar...(i was suspicious that this wouldn't work anyways because i have it set to notify me when a program is being blocked>

Fabio Zadrozny said...

Ok, can you create a bug-report with that?

Please add your eclipse version, pydev version, ipy version, a screenshot of your interpreter configuration and the error log you're getting.

See http://pydev.sourceforge.net/faq.html#how_do_i_report_a_bug for details on how to report it

Also, can you check if you have sys._getframe() properly (add that to the report too).

I'll take a better look at that tomorrow (I've tested things here with a clean eclipse 3.5 and the latest iron python and it worked here, so, it's probably some misconfiguration).

Anonymous said...

I sure will Fabio...I will have this ready for you tomorrow...thanks!

Anonymous said...

I entered the bug report. The ID is 2819033. Thanks again!

Anonymous said...

Fabio, as i was reviewing the screen shots i sent you I realized that i had the IronPython config page empty but the normal Python config filled up with IronPython stuff. Man...

So, i emptied the Python config and then filled up the IronPython config appropriately.

I now have this error:
PythonInterpreterManager:Interpreter is not properly configured!
Please go to window > preferences > PyDev > Python Interpreters
and configure it.
If this is not supposed to be a Python project, change the project
type on the
project properties to the project you want (e.g.: Jython project).
At: at org.python.pydev.ui.interpreters.
AbstractInterpreterManager.getDefaultInterpreter
(AbstractInterpreterManager.java:135)

Do i need to fill up the normal Python config page with Python 2.5 or something? I would not think that i would need to have the regular Python (CPython) installed...and btw, sorry for the misteps...

Anonymous said...

Boy, what an air head?! I went ahead and change the project properties to IronPython, like the error told me to!!! Now, all is working well...sorry for taking your time on all this...but, hey, it is working now for me and i will put it to good use!

Josh said...

I had a few problems with 1.4.7.2843 on Eclipse 3.5.

Using IronPython 2.6, I get the dreaded _getframe Attribute Error while trying to debug.

I tried to start from scratch and removed Ipy 2.6b2 as well as Ipy 2.0.2.

Now I can't install Ipy 2.0.2 as an IronPython interpreter. When I try, I get an error related to -X:Frames even though I clear that option out of the box before trying to install.

If I install IronPythons 2.0.2 and 2.6b2 as normal Python interpreters (not IronPython interpreters) things work better. If, in the VM options in the Debug Configuration I set -X:Frames, then debugging starts without errors on Ipy 2.6b2. However, no breakpoints are ever hit.

I need to figure out how to get Ipy 202 back in Eclipse...

Fabio Zadrozny said...

Right now, the debugger doesn't work on Iron Python 2.6 (or in any version of Iron Python) because its support is still not complete (although there's a chance that it'll be complete before Iron Python 2.6 final)

So, for now, you have to keep with Iron Python 2.6 -- without debugging support (other versions are unsupported because Pydev won't be able to do code-completion -- and a number of other things because of the lack of sys._getframe() support)