IronPython2 Documentation
repository·master·Indexed 21 days ago
https://github.com/ironlanguages/ironpython2An open-source implementation of the Python programming language designed to run on the .NET Dynamic Language Runtime (DLR). It enables seamless integration between Python and the .NET ecosystem, allowing the use of .NET Framework libraries within Python code and the compilation of Python files into .NET assemblies via the ipyc.exe CLI. This version features Unicode-by-default string semantics and provides specific environment variables like IRONPYTHONPATH to avoid conflicts with CPython.
What's inside IronPython2
- ZLIB.NET is a 100% managed version of the ZLIB compression library specifically designed for the .NET framework. It is based on the JZlib library and provides compression capabilities within a managed environment. It is licensed as freeware.
Overview of adodbapi
masteradodbapi is a Python DB-API 2.0 compliant module designed to facilitate connections to Microsoft ADO (ActiveX Data Objects) for various databases and data sources. It is fully implemented in Python and works with both CPython and IronPython.
Key features include:
- 100% DB-API 2.0 compliance.
- Support for
eGenix mxDateTime, Python 2.3datetimemodule, and Pythontimemodule. - Ability to define custom type conversions for database columns.
Overview of the IronPython 2 repository structure
masterThe
ironpython2repository is organized into several functional components that developers can use or extend:- IronPython: Contains the core compiler and runtime (
IronPython.dll). - IronPython.Tests: Contains targeted compiler and runtime unit tests, which are executed via a C# test harness.
- Public: Contains miscellaneous documentation and tutorials for end-users.
- Samples: Provides demonstration code, such as a comment checker and voice functionality.
- Scripts: Contains infrastructure scripts and helper utilities.
- StdLib: Contains the Python standard library imports.
- Tests: Contains general test suites.
Note: IronPython 3 is available at https://github.com/IronLanguages/ironpython3.
- IronPython: Contains the core compiler and runtime (
What is IronPython
masterIronPython is an open-source implementation of the Python programming language that is tightly integrated with the .NET Framework. It runs on the .NET Dynamic Language Runtime (DLR), allowing it to function as a dynamic language alongside static languages like C# and VB.NET.
Key capabilities include:
- Using .NET Framework libraries within Python code.
- Using Python code within other .NET languages.
- Importing DLL files compiled in other languages and accessing their functions directly.
Overview of the isapi Python extension
masterThe
isapipackage is a Python extension for Internet Server Application Programming Interface (ISAPI). It allows Python code to be used within an IIS (Internet Information Services) environment via ISAPI extensions.For practical implementation details and usage examples, refer to the
samplesdirectory within the package, specificallysamples\README.txt.How ISAPI filter loading works in IronPython
masterISAPI extensions in this environment rely on a two-file mechanism to bridge IIS and Python. This architecture ensures that different Python extensions on the same server remain isolated, each receiving its own thread-pool and avoiding conflicts with IIS filter ordering semantics.
To create an ISAPI extension, you must provide:
- A loader DLL: A special Python loader DLL (typically prefixed with an underscore, e.g.,
_MyIISModule.dll). IIS loads this DLL. - A Python module: A Python file that implements the logic, named by removing the leading underscore from the DLL name (e.g.,
MyIISModule.py).
When installing an extension, the installation process automatically checks for the existence of a loader DLL. If one is missing or if the standard loader differs from your implementation, the installer copies and renames the appropriate loader DLL to match your module name.
- A loader DLL: A special Python loader DLL (typically prefixed with an underscore, e.g.,
Interact with COM objects via the CLR
masterIn IronPython, interaction with COM (Component Object Model) objects is handled directly by the Common Language Runtime (CLR). This differs from CPython, which typically requires a Python library to bind to native COM DLLs.Understand IronPython string semantics and Unicode behavior
masterWhile IronPython is based on Python 2, its string handling behaves more like Python 3 to align with the Common Type System (CTS).
In IronPython, strings are Unicode by default. This means string literals and general string semantics are closer to Python 3 than the standard Python 2 behavior (where strings are ASCII and Unicode is a separate type).
What are Feature Symbols in IronPython2
masterFeature Symbols (prefixed withFEATURE_and in all caps) are compilation symbols used to manage features whose availability varies across different platforms supported by IronPython2. These symbols allow developers to write platform-agnostic code by checking for the existence of specific .NET types, APIs, or runtime capabilities at compile time. These symbols are defined in theBuild/{framework}.propsfile and are included in all.csprojfiles within the project.Set up a local development environment with a fork
masterTo contribute patches back to the project, it is recommended to fork the repository on GitHub first. After forking, follow these steps to configure your local Git environment and clone your personal fork while maintaining a connection to the upstream IronPython2 repository.
- Configure your global Git identity.
- Clone your personal fork.
- Add the original IronPython2 repository as a remote named
ironpython2to pull updates. - Pull the latest code from the upstream master branch.
git config --global branch.autosetupmerge true git config --global user.name "Jane Doe" git config --global user.email janedoe@example.com git clone git@github.com:janedoe/ironpython2.git cd ironpython2 git remote add ironpython2 git://github.com/IronLanguages/ironpython2.git git pull ironpython2 masterAccess documentation for isapi via PyWin32
masterDetailed documentation for
isapiand related Windows extensions is contained within thePyWin32.chmhelp file. You can access this documentation using one of the following methods:- Via Pythonwin: Open the
Pythonwinapplication and navigate toHelp. - Via Windows Start Menu: Search for the
PyWin32help file in your system's start menu.
- Via Pythonwin: Open the
Build IronPython2 from the command line
masterIronPython2 uses a PowerShell script
make.ps1for building and testing.Windows: Run commands directly in PowerShell. Linux/macOS: Prefix commands with
pwsh(requires PowerShell installation).To build in Release mode (default):
.\make.ps1To build in Debug mode:
.\make.ps1 debugAfter a successful build, binaries are located in:
ironpython2/bin/{ConfigurationName}/{Framework}.\make.ps1