Skip to content

FR: Port Install-IronPython and Implement Direct PowerShell Support #2601

Open
@anonhostpi

Description

@anonhostpi

SHILL DISCLAIMER: The reddit links are to my posts. Not trying to farm. I just don't know of anyone else who has already started work on this.

Background

A little known fact about PowerShell is that it too is also a CLR language just like C#. This means that .dll libraries written for C# can also be used in PowerShell.

IronPython currently takes advantage of this to make Python APIs available directly in PowerShell:

C# vs PowerShell and Applicability to Python.NET

One of the major differences between the 2 languages is how .nupkgs are treated. PowerShell expects them to be PowerShell modules and not bundled C# libraries. Natively, PowerShell doesn't know how to parse and handle .nupkgs pulled from NuGet. It's only designed to handle the ones provided by PowerShell Gallery.

This means that using the existing .nupkgs built for NuGet won't be usable out of the box. There are 2 options for implementing:

Utilize IronPython's Existing Solution (Recommended)

IronPython builds and ships a separate .zip archive to be used by ipy and powershell for easy embedding. You could just port this practice over the way it is. This method is also well-maintained

For more on how this method would be utilized, you can read about it here:

Implement a NuGet Package Parser in PowerShell (Not Recommended)

While this option is future proof and may come with other benefits, I don't recommend this option. It requires more work and more overhead. A strong argument could be made that this would be out of scope for this project.

I have done this before, but my solution is unmaintained. I also believe the most recent version is broken (older versions--older than version 0.4--reportedly work): https://github.com/pwsh-cs-tools/Import-Package

This uses NuGet's own C# libraries for parsing their own packages then uses that to break C# .nupkgs down into their relevant files for the target OS.

This is the other benefit. NuGet packages are currently designed to be digested at compile time. Developing this tool would not only allow them to be digested in PowerShell, but be digested at runtime in general, allowing C# developers to import .nupkgs as desired at runtime. Again, while nice, this is out of scope. So take that into consideration when deciding to add this to the stuff you want to maintain.

For more on how this method would be utilitized, you can read about it here:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy