#

#

# IronPython 2.6.1

IronPython is an implementation of the Python programming language on .NET. The .NET Framework is a managed programming model for Windows; Microsoft standardized part of it in ECMA several years ago as the Common Language Infrastructure and C# Language Specification standards.

IronPython is fast - up to 1.7x faster than Python-2.6 on the standard pystone benchmark. It supports an interactive interpreter with fully dynamic compilation. It is well integrated with the rest of the framework and makes the whole .NET Framework class library easily available to Python programmers.

You can get IronPython sources, binaries, and samples from www.codeplex.com/ironpython . You can also get news, file bugs, and generally interact with the IronPython team through this shared project site. There's a mailing list you can join for discussing issues and releases if you like.

There's a good introductory tutorial at IronPython Tutorial.

IronPython has a high degree of compatibility with CPython, but there are some differences. See IronPython Differences document for details.

IronPython 2.6.1 is suitable for building Python applications where you want to make use of .NET Framework and pure python modules. There are still some missing standard CPython libraries (See IronPython Differences for details.), and there are some known issues with the IronPython implementation (see www.codeplex.com/ironpython).

## Prerequisites

To run, IronPython 2.6.1 requires .NET Framework version 2.0 SP1 to be installed on your system. You can install the latest version from Microsoft:

- Microsoft .NET Framework Version 2.0 SP1 Redistributable Package

IronPython should also run on any platform that implements the CLI specification v2.0.

There are more prerequisites if you want to build IronPython from source.

## Running IronPython

If you did not download the binaries, you'll need to build IronPython first. After building IronPython or unpacking the binary distribution, you can complete the installation by adding the IronPython installation directory to your PATH. To test the installation, you should launch the interactive interpreter as shown below:

>     C:\IronPython>ipy
>     IronPython 2.6 on .NET 2.0.50727.4927
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> 2+2
>     4

You can use IronPython to run Python scripts by passing the script name on the command-line just as with standard Python. If hello.py had the displayed contents, the following ipy command line would run it:

>     Hello.py:

>     for i in xrange(3):
>         print "Hello World"

>     C:\IronPython>ipy Hello.py
>     Hello World
>     Hello World
>     Hello World

This simple example shows how you can start using WinForms from IronPython:

>     C:\IronPython>ipy
>     IronPython 2.6 on .NET 2.0.50727.4927
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> import clr
>     >>> clr.AddReference("System.Windows.Forms")
>     >>> import System.Windows.Forms as WinForms
>     >>> WinForms.MessageBox.Show("Hello", "Hello World")
>     System.Windows.Forms.DialogResult.OK

For more information on the clr.AddReference function, see the Loading .NET Libraries exercise in the IronPython Tutorial, which has many examples of using IronPython in various ways.

## Building IronPython from Source

If you downloaded the binaries from www.codeplex.com/ironpython, you do not need to build it. To compile IronPython from the source code, you can use either Visual Studio 2008, Visual C# 2008 Express Edition or MSBuild.

### Building using Visual Studio 2008 or Visual C# 2008 Express Edition

Open IronPython.sln in Visual Studio or Visual C# Express and build (from menu: Build->Build Solution). Set IronPythonConsole as your startup project in the Solution Explorer.

### Building using MSBuild

The .NET Framework v3.5 comes with Microsoft's C# compiler and MSBuild utility. After installing the framework, open up a command prompt, cd to the IronPython directory, and execute:

>     c:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe IronPython.sln

This will build IronPython.dll, IronPython.Modules.dll, Microsoft.Scripting.dll, Microsoft.Scripting.Core.dll, ipy.exe, and ipyw.exe.