Friday, July 6, 2012

What’s new in IronPython 2.7.3

IronPython 2.7.3 is now available, and this is a quick look at some of the new features.

New Modules

Three new modules have been added: bz2, winsound, and _bisect.

The bz2 modules implements compression and decompression using the bzip2 algorithm; in particular, it allows (in conjunction with the already supported tarfile module) reading .tar.bz2 files. It is implemented in pure C# using code from the DotNetZip Library.

The winsound module gives access to the standard Windows sound functions, such as winsound.MessageBeep().

The _bisect is an accelerator module for the pure-Python bisect module that was already supported.

The _ast module was given a major upgrade to make it compatible with CPython 2.7. Finally, many other modules saw bugfixes small and large.

Loading zip packages from resources

IronPython 2.7.2 added the ability to load Python code from zip files; in 2.7.3 this has been extended to support zip files stored as resources. Because this only makes sense when hosting IronPython, it is not directly accessible from Python code. Instead, the hosting application has to add the resources, like so:

class Program
{
static void Main(string[] args)
{
var assembly = typeof (Program).Assembly;
const string resourceName = "python_27_lib.zip";
var importer = new IronPython.Modules.ResourceMetaPathImporter(assembly, resourceName);

var engine = IronPython.Hosting.Python.CreateEngine();
dynamic sys = IronPython.Hosting.Python.GetSysModule(engine);
sys.meta_path.append(importer);

var script = "import os" + Environment.NewLine + "os.name";
var result = engine.Execute(script);

Console.WriteLine("os.name: {0}", result);
Console.ReadKey();
}
}

Mobile Support


The support for Android has been improved slightly; IronPython apps can now be run on actual hardware. Writing them is a bit tricky because of limitations in Mono for Android, but hopefully that will be improved for IronPython 2.7.4


Windows Phone support has been dropped because there were serious issues with the current version, and WP7’s days are numbered. Instead focus will shift to WinRT (“Metro”) which will work in Windows 8 and Window Phone 8.


Other Improvements


The pyc.py compiler (in Tools\Scripts) gained the ability to use response files for large command lines. The syntax is the same as most other Microsoft tools, like csc.exe: pyc.py @response.txt.


Many other bugs have been fixed, improving the overall quality of the release in many different areas.


Thanks


Special thanks goes to Alex Earl, Keith Rome, and Pavel Jasinski for their contributions, and the countless people who submitted bug reports, and of course, all of the IronPython users.

Friday, June 29, 2012

IronPython 2.7.3 Release Candidate Available

The first (and hopefully only) release candidate for IronPython 2.7.3 is now available. There are two major changes since the beta: first, the incompatibility with IronRuby 1.1.3 has been fixed, and second, assemblies for Windows Phone 7 are no longer included. The WP7 assemblies were removed because they are basically useless in their current state, and WP7 has a dwindling useful life. If someone wants to commit to maintaining them, send a message to the mailing list or @ironpython.

If there are no issues with the release candidate, 2.7.3 will be released on July 4.

IronPython 2011 Usage Survey Results

At long last, I’m uploading the results from the IronPython usage survey last December. I had held off on posting them because I wanted to do a nice big post with lots of examples, but I just don’t think I’ll ever find the time. Instead, I’ve uploaded the spreadsheet for anyone who’s interested.

IronPython 2011 Usage Survey Results (xlsx)

Sunday, June 10, 2012

IronPython 2.7.3 Beta 1

The next version of IronPython, 2.7.3, has reached the beta stage, and you can get it right here. There are no major new features since the last alpha, just a stack of small bug fixes. The only new feature is an implementation of PEP 421, which adds a new attribute to the sys module, sys.implementation, that contains information to consistently identify the current Python implementation.

The final release of 2.7.3 is targeted for July 1, so please test this release out and report any issues so that they can be fixed prior to that.

Sunday, April 29, 2012

IronPython 2.7.3 Features: the SuperConsole

Internally, IronPython has two implementations of the console: BasicConsole and SuperConsole. The BasicConsole is very simple with no extras, while the SuperConsole has line history and tab completion added. Prior to 2.7.3, the BasicConsole was the default, but starting with 2.7.3 the SuperConsole is the default.

The main reason for this is the difference between Windows and Unix systems: on Windows the console provides line history for every application, while on Unix each program has to implement it for itself. In practice, Unix apps use something like GNU readline to implement it, but IronPython can’t use a native library.

I was all set to write the history code when I discovered that the SuperConsole already had it! It also has tab completion, which the default CPython shell lacks (although the brilliant IPython does have it). Once you get used to having tab completion in the shell, it’s really hard to go back.

The SuperConsole has been tested on multiple platforms and seems to work just fine, but if you have any issues you can switch back to the BasicConsole by passing -X:BasicConsole to ipy.exe. Also, please create an issue if you have any difficulty with the new console.

IronPython 2.7.3 Alpha 1 Available

The first preview release of IronPython 2.7.3 is now available. This release includes new modules, improvements to pyc.py, and several other enhancements (and more are coming before 2.7.3 is released).

Unfortunately, there is an issue with having both IronPython 2.7.3 (and 2.7.2, actually) and IronRuby 1.1.3 installed at the same time, so if you want to use IronPython you must uninstall IronRuby. This will be resolved before the final IronPython 2.7.3 release.

Wednesday, April 4, 2012

IronPython & Google Summer of Code 2012

The student application deadline for Google Summer of Code 2012 is coming up this Friday (April 6th). GSoC is a program where Google pays students to work on open-source code over the summer, and I would very much like to see some work done for IronPython. If you're a student, you're interested in
IronPython, and you want to get paid to work on it, this is yourchance. Check out the ideas page, which also directs you where to apply.


A huge thank-you to the Mono project for allowing us to use their slots if we get some good applications.

Monday, March 12, 2012

IronPython 2.7.2.1

There was fairly serious regression introduced between 2.7.2 RC1 and 2.7.2 final – see issue #32400 for details. Upgrading to 2.7.2.1 is highly recommended.

On the plus side, this isn’t a dataloss bug, or anything like that, just a “break almost every program in existence” bug. Basically, the code for checking for comparison operators got broken. The motivating example is

if sys.version_info < (2, 4):
# do something

I’m sure other cases would be broken as well, so I decided to err on the side of caution and update the release as soon as possible. My apologies to everyone who already downloaded 2.7.2 and was impacted by this.

Sunday, March 11, 2012

IronPython 2.7.2 Now Available

IronPython 2.7.2 has now been released. Take a look at last week’s post about what’s new for more details. There will be more posts in the next few days taking a look at some of the new features in 2.7.2, so watch this space!

Sunday, March 4, 2012

What’s New in IronPython 2.7.2?

With IronPython 2.7.2 RC now available, the feature set for 2.7.2 is now finalized. The major features for this release are zipimport, the sqlite3 module, pyc.py improvements, and preliminary support for Android and Windows Mobile 7, some changes to the package layout, and NuGet packages.

zipimport

The zipimport module allows IronPython to import modules from a .zip file. To use it, simply add the path of the .zip file to sys.path, and it will automatically be searched.

sqlite3

The sqlite3 module provides access to sqlite3 databases. It uses the csharp-sqlite library so that the implementation is fully managed, which means that it will work from Silverlight, Android, and Windows Phone as well.

Improvements to pyc.py

The pyc.py script (in Tools\Scripts\pyc.py) is now able to generate standalone exectuables. For example, you could use it to generate a standalone version of pyc.py:
> ipy Tools\Scripts\pyc.py /target:exe /standalone /main:Tools\Scripts\pyc.py

Mobile Support

IronPython 2.7.2 includes preliminary support for Android and Windows Phone 7.5 development (iOS support is still planned, but it’s much more difficult). Android requires using Xamarin’s Mono for Android, while Windows Phone is supported natively. Both platforms are similar to Silverlight yet also very different, and Android is far more capable.

There’s currently no help in setting up the app; use the normal templates for the platform, and then embed IronPython in the app. There’s a lot more work to be done in this area, which is why these are considered preliminary. If you try to use them in production we’d love bug reports, but you still get to keep the pieces.

Packaging Changes

Both the installer and and zip package now have a Platforms directory that contains the assemblies for every platform supported by IronPython (.NET 4, .NET 3.5, Silverlight 4, Silverlight 5, Android, and Window Phone 7.5). This makes it much easier to reference the appropriate platform assemblies from your project.

NuGet

Finally, the IronPython NuGet package has been updated to 2.7.2. The main “IronPython” package only contains IronPython itself; the standard library is in “IronPython.StdLib”. The RC isn’t available through the UI (because it’s a prerelease version), so you’ll have to run “Install-Package IronPython –IncludePrerelease” from the Package Manager Console to install it. For the final release this will unnecessary.