IronPython2 Documentation

repository·master·Indexed 21 days ago

https://github.com/ironlanguages/ironpython2

An 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.

Tokens
33K
Snippets
99
Records
155
Agent score
77%

What's inside IronPython2

  1. Overview of adodbapi

    master

    adodbapi 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.3 datetime module, and Python time module.
    • Ability to define custom type conversions for database columns.
  2. Overview of the IronPython 2 repository structure

    master

    The ironpython2 repository 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.

  3. What is IronPython

    master

    IronPython 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.
  4. Overview of the isapi Python extension

    master

    The isapi package 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 samples directory within the package, specifically samples\README.txt.

  5. How ISAPI filter loading works in IronPython

    master

    ISAPI 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:

    1. A loader DLL: A special Python loader DLL (typically prefixed with an underscore, e.g., _MyIISModule.dll). IIS loads this DLL.
    2. 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.

  6. Understand IronPython string semantics and Unicode behavior

    master

    While 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).

  7. What are Feature Symbols in IronPython2

    master
    Feature Symbols (prefixed with FEATURE_ 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 the Build/{framework}.props file and are included in all .csproj files within the project.
  8. Set up a local development environment with a fork

    master

    To 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.

    1. Configure your global Git identity.
    2. Clone your personal fork.
    3. Add the original IronPython2 repository as a remote named ironpython2 to pull updates.
    4. 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 master
  9. Build IronPython2 from the command line

    master

    IronPython2 uses a PowerShell script make.ps1 for 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.ps1

    To build in Debug mode:

    .\make.ps1 debug

    After a successful build, binaries are located in: ironpython2/bin/{ConfigurationName}/{Framework}

    .\make.ps1