Skip to content
Lamparter edited this page Nov 17, 2024 · 4 revisions

IronPython Console

IronPython is a popular, open-source implementation of Python 3.x for .NET that is built on top of its very own Dynamic Language Runtime.

To install and run IronPython, follow these steps:

  1. Download the release binary appropriate for your system from the releases page.
  2. Install the package by clicking on it and going through the installer.

In order to use IronPython:

  1. Run the ipy command to start the IronPython console - while not in the system PATH variable, the IronPython installer generally adds the console to the computer's Programs menu, or the Start menu on Windows.
  2. You can then execute Python code directly, using the .NET runtime libraries as needed.

Start menu image

You can then interact with the IronPython Console as shown below.

The following C# program:

using System.Windows.Forms;

MessageBox.Show("Hello World!", "Greetings", MessageBoxButtons.OKCancel);

can be written in IronPython as follows:

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import MessageBox, MessageBoxButtons

MessageBox.Show("Hello World!", "Greetings", MessageBoxButtons.OKCancel)

IronPython targets .NET Standard 2.0, .NET Framework 4.6.2, .NET 6 and .NET 8.

🙋 Contributing

Here are some ways you can contribute:

  • Update documentation.
  • Identify and fix failing tests.
  • Check out our good first issues.

⚖️ License

IronPython is licensed under the Apache License 2.0.

Copyright (c) .NET Foundation and Contributors.


Note

These are the original IronPython development notes created by the IronLanguages development team. They are old and outdated; the new and updated guide can be found in the sidebar.

Copy commits from main

Copy commits from the main repository to the ironpython3 repository:

pushd ironlanguages-main
git checkout $branch
git format-patch -o $branch-patches $(git merge-base -a master $branch)
git checkout -
popd
pushd ironpython3
git checkout -b $branch
git am --include="*/Languages/IronPython/*" -p 3 --directory=Src ../ironlanguages-main/$branch-patches/*
# fix merge conflicts as needed
popd
rm -r ironlanguages-main/$branch-patches

This can be tweaked to update a branch by not using -b on checkout and changing the use of merge-base to a hardcoded revision. Commits that update files outside of Languages/IronPython may need extra include lines, although the directory structure is similar enough (for this reason) that it should just work. Worst case, edit the patch files by hand before using git am (the hashes will change anyway).

Something similar can be done for the Dlr as well by tweaking the paths.

Copy commit to main

As above, but change the patching line to:

git am --include="*/Src/*" -p 3 --directory=Languages/IronPython ../ironpython3/$branch-patches/*