|
| 1 | +IronPython |
| 2 | +========== |
| 3 | + |
| 4 | +IronPython is an open-source implementation of the Python programming language that is tightly integrated with .NET. IronPython can use .NET and Python libraries, and other .NET languages can use Python code just as easily. |
| 5 | + |
| 6 | +This archive contains the IronPython executables usable for all supported platforms and systems. The executables require a .NET Runtime to be present on the system (not necessarily a .NET SDK). The archive also includes the Python Standard Library released by the Python project, but slightly modified to work better with IronPython and .NET. |
| 7 | + |
| 8 | +The current target is Python 3.4, although features and behaviors from later versions may be included. Refer to the [source code repository](https://github.com/IronLanguages/ironpython3) for list of features from each version of CPython that have been implemented. |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +After unpacking the archive, move or copy one of the `net` directories matching the desired runtime to use to a desired location. The name of the directory may be changed to something more appropriate, but its structure (subdirectories) should remain intact. |
| 13 | + |
| 14 | +If access to the Python Standard Library is desired from IronPython, move or copy the whole `lib` directory **into** the moved/copied directory from the previous step. The `lib` directory has to be in the same directory as `IronPython.dll`. |
| 15 | + |
| 16 | +## Command-line Usage |
| 17 | + |
| 18 | +To start a command-line interpreter on Windows run `ipy.exe` (for .NET Framework) or `ipy.bat` (for .NET). On Posix systems, run `ipy.sh`. `ipy.sh` may be renamed to simply `ipy` for convenience. |
| 19 | + |
| 20 | +Run `ipy -h` for a summary of command-line options. Most are identical to CPython, but there are a few IronPython-specific options. |
| 21 | + |
| 22 | +When reporting issues on [IronPython Project Issues page](https://github.com/IronLanguages/ironpython3/issues), provide the output of `ipy -VV` in the report. |
| 23 | + |
| 24 | +## Embedding IronPython Engine |
| 25 | + |
| 26 | +To embed an IronPython interpreter in a .NET application, simply add references to the DLLs present in the installation directory to your project. |
| 27 | + |
| 28 | +### Example |
| 29 | + |
| 30 | +Execute Python code and call it from .NET code: |
| 31 | + |
| 32 | +```cs |
| 33 | +var eng = IronPython.Hosting.Python.CreateEngine(); |
| 34 | +var scope = eng.CreateScope(); |
| 35 | +eng.Execute(@"if True: |
| 36 | + def greetings(name): |
| 37 | + return 'Hello ' + name.title() + '!' |
| 38 | +", scope); |
| 39 | +dynamic greetings = scope.GetVariable("greetings"); |
| 40 | +System.Console.WriteLine(greetings("world")); |
| 41 | +``` |
| 42 | + |
| 43 | +## Differences with CPython |
| 44 | + |
| 45 | +While compatibility with CPython is one of our main goals with IronPython 3, there are still some differences that may cause issues. See [Differences from CPython](https://github.com/IronLanguages/ironpython3/blob/master/Documentation/differences-from-c-python.md) for details. |
| 46 | + |
| 47 | +## Package compatibility |
| 48 | + |
| 49 | +See the [Package compatibility](https://github.com/IronLanguages/ironpython3/blob/master/Documentation/package-compatibility.md) document for information on compatibility with popular packages. Note that to run most packages, IronPython Standard Library must be present. |
0 commit comments