From IronPython Cookbook

Revision as of 20:18, 19 June 2007 by MichaelFoord (Talk | contribs)

This article aims to provide complete information about how to deploy IronPython scripts to client computers.



Both the IronPython interpreter and runtime are made of Microsoft Intermediate Language (MSIL), meaning that it is bytecode like all .NET programs. Therefore it requires the IronPython binaries and either the .NET Framework 2.0 (Windows) or Mono (*nix). All files from the IronPython distribution are not required to run IronPython scripts on Windows. Therefore the following must be true about the machine.

.NET 2.0 or 3.0 installed
IronPython binaries exist in the same folder
*nix (Linux, Unix, Macintosh)
Mono installed
FePy - IronPython community distribution, includes the CPython library.

For information on how to aquire any of the above please see the Downloads article.

Python Libary

The standard CPython library must be installed on the target machines if the client is a Windows machine and the libary is used. A clear give-away is when the following code exists in any of the python files:

# If this code appears in an IronPython file, the file
# requires the standard CPython library to be installed.

Please refer to Using the Python Standard Library for more information on when and how the standard Python library is used.

.NET 3.0

The .NET 3.0 framework is required on the target computer whenever any of the enclosed classes are used. If the author uses the words Windows Communication Foundation (WF), Windows Workflow Foundation (WWF), Windows CardSpace (WCS), Windows Presentation Foundation (WPF), or XAML then the file is likely to require the .NET Framework 3.0.

Some examples of statements which require .NET 3.0:

# If any of the following statements exist within an IronPython file,
# it requires the .NET 3.0 framework to be installed.

clr.AddReference("PresentationCore")	# WPF
# To be appended:	# references for WCF, WCF, WWF

File Associations

File associations can be created so that whenever a .py script is double-clicked, it will call the IronPython interpreter. You should think twice about modifying any file associations if the standard CPython library has been installed as you may break some standard Python programs.

You can set up file associations in Windows XP by following these instructions:

  1. Double-click "My Computer" on the desktop.
  2. Click on the "Tools" menu.
  3. Click the "Folder Options" menu item.
  4. Click the "File Types" tab, it may take a few moments to load.
  5. Scroll down to the "PY" extension...
    1. If it does not exist then you can add it to the list by hitting the "New" button.
    2. If an association already exists then click the "Change" button to change it.
    3. If you want to right-click and choose "Run" then click the "Advanced" button.
  6. In any case point the extension to the "ipy.exe" IronPython interpreter.

Back to Contents.