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.
There's a huge base of third-party libraries for IronPython. Generally, you don't need to install any third-party libraries to use this book. Everything you need to work with IronPython is included with the download you get from the CodePlex Web site. The only time you might need to work with third-party libraries is in Part IV. You'll receive specific instructions in the Part IV chapters for any required third-party libraries, so you only need to read "Using Third-Party Libraries" if you plan to work with third-party libraries immediately.
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.
(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
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.
Most developers will likely use the standard version of IronPython that works with the .NET Framework 3.5 and earlier. However, you might need some of the new features in the .NET Framework 4.0, such as the C# dynamic keyword, which is part of the Dynamic Language Runtime (DLR) (http://dlr.codeplex .com/). The section "Understanding the Dynamic Language Runtime" later in this chapter tells you more about this .NET 4.0 feature. You can obtain this version of IronPython at http://ironpython.codeplex.com/Release/ProjectReleases .aspx?ReleaseId=27320. The examples in this book will work with either version of IronPython 2.6, except where noted (where I'm demonstrating how to work with the DLR).
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).
When you perform a DLR installation, you'll see a Do Not NGen Installed Binaries option on the Custom Setup dialog box. Using the Native Image Generator (NGen) can greatly improve application performance, as described at http://msdn.microsoft.com/en-us/magazine/cc163610.aspx. Earlier versions of IronPython didn't use NGen to build the libraries for you by default. You had to use a special command line to obtain the NGen feature (msiexec /qn /i "IronPython.msi" NGENDLLS=True). The default setup for IronPython 2.6 is to use NGen to build the libraries.
However, using NGen also binds the binaries to the local machine, which may not be what you want when working in a dynamic environment. Consequently, if you plan to use DLR more than you plan to use other IronPython features, you might want to check the Do Not NGen Installed Binaries option.
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.
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.
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.6\Src 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 O Build Solution. Visual Studio creates the required DLLs, ready for testing.
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:
ri HliTfcnnaltcT.il fi] HWllcqKIÏWl.Q HrçiKiTWT.iTT
J HL1u5«ti(.uï fi] unajflflçinfc.a h^nrTspfSirtHi^
m là Hiuuciici
IU .J CMfcr
_| Uh Iii hj-itmr r] M»,H»Jfel^ïdF™.!^! IlJmI».I I .r. Kts^yoM.rts*
3 IfnWitvHi.MMUn ■ J P'UCJTllCl .11 J hcfft-ict! nj Za riwn
FIGURE 1-2: IronPython consists of multiple projects, so you must compile the entire solution.
(L 4) IronPython is a complex product. If you fail to compile the entire solution every time you make a change, you could end up with an unworkable group of DLLs due to interactions. It's important to build everything so that any changes propagate properly.
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.
Was this article helpful?