Getting IronPython

0
182

Before you can use IronPython, you need to get a copy of your own, install it, and check to make sure it works. Theoretically, you might want to obtain the source code and build your own version of IronPython, but most developers simply download the binaries and begin working with IronPython right away. The first three sections that follow tell you what you need to work with IronPython, how to obtain the software, and how to install it. You’ll definitely want to read these sections.

The final two sections are completely optional. In fact, you may want to skip them for now and come back to them after you complete more chapters in the book. The first optional section tells you how to build your own copy of IronPython from the source. The second optional section tells you about third-party libraries.

Understanding the IronPython Requirements

As with any software, IronPython has basic system requirements you must meet before you can use it. It turns out that there are actually two versions of IronPython 2.6 — one for the .NET Framework 2.0, 3.0, and 3.5, and a second for the .NET Framework 4.0. Here are the requirements for the .NET Framework 2.0, 3.0, and 3.5 version.

  • The .NET Framework 2.0, 3.0, and 3.5
  • (Optional) Visual Studio 2005 or Visual Studio 2008 (your system must meet the prerequisites for this software)
  • (Optional) .NET Framework 2.0 Software Development Kit (SDK)

You need only the optional requirements if you plan to build IronPython 2.6 from the source code. Here are the requirements for the .NET Framework 4.0 version (again, the optional requirements are there if you want to build IronPython from source code).

  • The .NET Framework 4.0
  • (Optional) Visual Studio 2010

Getting the Software

As with most open source software, you have a number of choices when it comes to downloading IronPython. For the sake of your sanity, the best choice when starting with IronPython is to download the binary version of the product from http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30315. You’ll see the Microsoft Installer (MSI) link right below the Recommended Download link as IronPython-2.6.msi. If you really must save the few seconds downloading the MSI version, select the IronPython-2.6-Bin.zip link instead.

It’s also possible to compile IronPython from the source code. If you want to use this option, select the IronPython-2.6-Src.zip link. You must have a copy of Visual Studio installed on your system to use this option. The “Building the Binaries from Scratch” section of the chapter describes how to build a version from scratch, but this process truly isn’t for the IronPython beginner and doesn’t serve much of a purpose unless you plan to add your own enhancements.

Performing the Installation

This section assumes that you’ve downloaded the MSI file to make life easy for yourself. This procedure works equally well for either version of IronPython 2.6 so you can use it for a DLR install as well. The following instructions help you get IronPython installed on your machine.

  1. Double-click the MSI file you downloaded from the CodePlex Web site. You’ll see the usual Welcome page — click Next to get past it.
  2. Read the licensing agreement, check I Accept the Terms in the License Agreement, and then click Next. You’ll see the Custom Setup dialog box shown in Figure 1-1 where you can select the IronPython features you want to install. At a minimum, you must install the Runtime. The Documentation, Standard Library, and Tools features are also strongly recommended. This book assumes that you’ve installed all the features. However, you might want to install just those features you actually need for a production setup (you might not actually need the samples).

    Choose the features you want to install.

  3. Select the features you want to install. Click Next. You’ll see a summary dialog box that simply states you’re ready to install IronPython.
  4. Click Install. MSI will begin the installation process. At some point, you’ll see an installation completion screen.
  5. Click Finish. You should be ready to begin working with IronPython at this point.

Building the Binaries from Scratch

You may eventually want to build the IronPython binaries from scratch. The normal reason to perform this task is to create a special version of IronPython that meets specific needs. A company may want to add extensions or special features to IronPython. Because you have the source code, it’s acceptable to create a custom version of IronPython for yourself — one that contains any feature set you deem necessary to get your work completed. So have fun molding IronPython and then sharing your modifications with others. In order to perform this task, you must have a copy of Visual Studio (you must have Visual Studio 2010 to build a DLR version of IronPython). The following steps tell you how to build the IronPython 2.6 binaries from scratch.

IronPython consists of multiple projects, so you must compile the entire solution.

  1. Download the source code file, such as IronPython-2.6-Src.zip.
  2. Extract the files into a folder. The example assumes that you extracted the files into the root directory of your hard drive into IronPython-2.6.
  3. Locate the IronPython-2.6Src directory and open the IronPython.sln solution using Visual Studio. Visual Studio will load the required files, and you’ll see them in Solution Explorer, as shown in Figure 1-2. Figure 1-2 shows that IronPython consists of a number of projects — you must compile the entire solution to obtain a workable group of DLLs.
  4. Make any required changes to the source code.
  5. Choose Build ➪ Build Solution. Visual Studio creates the required DLLs, ready for testing.

Using Third-Party Libraries

Python is an extremely flexible language and enjoys strong third-party support. In fact, you can find lists of these libraries in various places on the Internet. Here are a few places to check:

  • http://code.google.com/appengine/docs/python/tools/libraries.html
  • http://www.amaltas.org/show/third-party-python-libraries-and-frameworks.html
  • http://dakrauth.com/blog/entry/third-party-python-libraries-interest/

You should be able to use some third-party libraries with IronPython. At the time of this writing, you won’t actually find any usable third-party libraries. However, you should check http://www.ironpython.info/index.php/Third-Party_Library_Compatibility from time-to-time to discover whether there are any third-party libraries that do work with IronPython. It’s important to note that this list represents only tested libraries — you may find other third-party libraries that do work with the current version of IronPython.