ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

Initial creation of the IronPython SDK

Open Lamparter opened this issue 8 months ago • 17 comments
trafficstars

This is an initial start at creating IronPython.Sdk, which allows you to enjoy the beautiful SDK-style project feature that modern .NET uses.

This SDK is also compatible with non-IronPython projects.

Lamparter avatar Mar 15 '25 12:03 Lamparter

For example

image

An IronPython project should probably look like:

<Project Sdk="IronPython.Sdk" ToolsVersion="4.0">
  <PropertyGroup>
    <!-- Below is the default, but you can also specify "CPython" -->
    <PythonInterpreter>IronPython</PythonInterpreter>
    <PythonVersion>3.4</PythonVersion>
  </PropertyGroup>
</Project>

Lamparter avatar Mar 15 '25 12:03 Lamparter

Tell me this isn't awesome 😁 image

Lamparter avatar Mar 15 '25 13:03 Lamparter

Is it intended to work on macOS/Linux too? If it supports the debugger in VSCode it will be awesome! I have noticed many people were struggling with IronPython debugging.

On a more practical side, how about placing the SDK in src/tooling/IronPython.Sdk (i.e. rename sdk to tooling). In this way the directory can logically contain other, non-SDK tooling. For example, I am working (well, was working) on IPython/Jupyter support. So far it works without significant workarounds, but the version for Python 3.4 is no longer supported, so it is conceivable that some dedicated fork for IronPython will be needed. Another project idea is scaffolding for pylint or another linter) that understands CLR and .NET namespaces.

BCSharp avatar Mar 17 '25 04:03 BCSharp

I know some Visual Studio engineers as well and I've been wondering about creating a Visual Studio/VS Code extension for using IronPython easily.

In VS Code the experience should be the same as with Python, and interacting with IronPython projects should be kept minimal - perhaps via a CLI to make it easiest

Lamparter avatar Mar 17 '25 07:03 Lamparter

And yes, SDK style projects are supported by the dotnet.exe command, meaning that they can build on macOS/Linux in theory.

Lamparter avatar Mar 17 '25 07:03 Lamparter

Another project idea is scaffolding for pylint or another linter) that understands CLR and .NET namespaces.

Unless I remember wrong, PTVS included this as well.

Lamparter avatar Mar 17 '25 07:03 Lamparter

Neat. I guess this is meant to be a replacement for the PTVS pyproj? The pyproj support in Visual Studio isn't too bad (though it's using the old ugly non-SDK style projects). Although no debugging for IronPython. 🤷

For my personal use case being able to easily pick interpreters/environments is important. PTVS does something like this to define interpreters:

  <ItemGroup>
    <InterpreterReference Include="Global|IronPython|3.4" />
    <InterpreterReference Include="Global|PythonCore|3.9" />
  </ItemGroup>
  <ItemGroup>
    <Interpreter Include="env\">
      <Id>env</Id>
      <Version>3.4</Version>
      <Description>env (IronPython 3.4 (64-bit))</Description>
      <InterpreterPath>Scripts\ipy.exe</InterpreterPath>
      <WindowsInterpreterPath>Scripts\ipy.exe</WindowsInterpreterPath>
      <PathEnvironmentVariable>IRONPYTHONPATH</PathEnvironmentVariable>
      <Architecture>X64</Architecture>
    </Interpreter>
  </ItemGroup>

Not saying it's the best thing to do... I like auto-detect that VSCode does to detect interpreters (although it doesn't handle IronPython very well).

slozier avatar Mar 17 '25 13:03 slozier

The project extension will still be pyproj (I think this will work, there's no actual way of knowing until the SDK gets published)

Lamparter avatar Mar 17 '25 15:03 Lamparter

This will be ready soon, no idea why the CI is suddenly failing. I want to split this into multiple PRs. I'm also interested in adding support for the built-in Visual Studio "Build" and "Rebuild" commands using ipyc.

Lamparter avatar Mar 22 '25 10:03 Lamparter

I also want to add proper support for PackageReference.

Lamparter avatar Mar 22 '25 10:03 Lamparter

Question: will there a plan to continue ironclad3?

GeorgeS2019 avatar Mar 27 '25 14:03 GeorgeS2019

Update your main to the new main tip from the IronPython repo, then rebase your branch (starting from commit a5b0c4f) onto the new main tip. The rebase should proceed without conflicts.

BCSharp avatar Mar 30 '25 20:03 BCSharp

Yep, just strange that it happened.

Lamparter avatar Mar 30 '25 20:03 Lamparter

It's because I force-pushed the main branch, apologies. You will need to force-push your rebased branch too.

BCSharp avatar Mar 30 '25 20:03 BCSharp

@slozier this PR is ready for review

Lamparter avatar Apr 02 '25 15:04 Lamparter

@slozier?

Lamparter avatar Apr 10 '25 13:04 Lamparter

@slozier?

Sorry, I just need to find more than 5 minutes to sit down and properly try it out.

slozier avatar Apr 10 '25 14:04 slozier

The SDK seems not supports compiler. Maybe we need a MSBuild Task pyc to support it. https://github.com/wherewhere/MSBuild.Sdk.Extras/blob/main/Source/MSBuild.Sdk.Extras.PY/targets/MSBuild.Sdk.Extras.PY.targets

wherewhere avatar Aug 31 '25 10:08 wherewhere