Skip to content

Conversation

@ivaylo-matov
Copy link
Contributor

Purpose

Draft PR — for review (please do not merge)

@mjkkirschner @twastvedt @zeusongit
Could you please review whether the approach is correct. The changes assume we’re still shipping DSPythonNet3 as a built-in package (same model as TuneUp) and that a future NuGet delivery will not require significant setup changes.

Problem:
Currently Dynamo uses the in-repo DSCPython project and the DLLs under \extern\Python, which are copied to \bin when Dynamo is built. By adding \extern\PythonNet3Engine (copied to \bin\Built-In Packages\packages\PythonNet3Engine), we end up with two Python.Runtime.dll files. Even if they target the same Python version, having two assemblies with the same identity on the probing path is fragile. We should use a single source of truth — the one that ships with DSPythonNet3.

What I’ve done:

  1. src logic: Implemented new functionality (identical to DYN-9388 Make PythonNet3 default python engine as built-in package #16548)
  2. Tests: Pointed tests to DSPythonNet3 methods where applicable
  3. Extern cleanup:
  • removed the entire \extern\Python folder so we have a single source of truth from \extern\PythonNet3Engine
  1. PythonMigrationViewExtension:
  • removed DSCPython reference.
  • switched Python.Runtime to the DSPythonNet3 version (build uses the copy under \extern\PythonNet3Engine\extra; at runtime Dynamo loads the copy under \bin\Built-In Packages\packages\PythonNet3Engine\extra).
  • minor ScriptMigrator updates for Python 3.11 behavior.
  1. DynamoPythonTests:
  • removed DSCPython reference
  • added DSPythonNet3 reference
  • aligned Python.Runtime to the DSPythonNet3 version (same compile-time/runtime pattern as above)
  1. Test logic changes:
  • CodeCompletionTests: now explicitly loads DSPythonNet3 in Setup()
  • PythonEvalTests: added [OneTimeSetUp] to load DSPythonNet3 and fetch DSPythonNet3Evaluator
  • PythonDependenciesTests: replaced the PythonNet3 package with the IronPython package
  1. Solution:
  • removed DSCPython from the solution

Current status:
Most Python tests pass with this approach; a few are still failing (I’ll tale a look those now). Please confirm if:

  • using only the DSPythonNet3 Python.Runtime.dll is acceptable (single source of truth).
  • the compile-time vs runtime reference pattern above is OK for now (build from extern, load from Built-In Packages).

Thanks!

Declarations

Check these if you believe they are true

Thanks!

Release Notes

Draft Pr to review if current strategy and test setup is correct and pparopriate.

Reviewers

@zeusongit

FYIs

@dnenov

ivaylo-matov and others added 26 commits September 3, 2025 09:42
cpython still present but does not load
CPythonClassCanBeReturnedAndSafelyDisposedInDownStreamNode
testing stuff

CPythonClassCanBeReturnedAndSafelyDisposedInDownStreamNode

few test fixed
Copilot AI review requested due to automatic review settings October 8, 2025 11:05
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9388

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new PythonNet3 engine to replace the legacy CPython3 engine in Dynamo, transitioning to DSPythonNet3 as the built-in Python engine. The change removes the entire DSCPython project and updates all test files and engine references to use PythonNet3 instead of CPython3. The new engine is distributed as a built-in package similar to TuneUp, with a migration system that automatically converts CPython nodes and notifies users about the engine change.

Key Changes:

  • Replaced CPython3 engine with PythonNet3 engine throughout the codebase
  • Removed DSCPython project and dependencies from solution files
  • Added migration notifications and automatic conversion of legacy CPython nodes

Reviewed Changes

Copilot reviewed 96 out of 138 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/**/*.dyn Updated Python engine references from "CPython3" to "PythonNet3"
test/Libraries/DynamoPythonTests/*.cs Updated test code to use DSPythonNet3 APIs and engine names
test/DynamoCoreTests/*.cs Removed DSCPython dependencies and updated engine references
src/Libraries/DSCPython/* Complete removal of DSCPython project files
src/PythonMigrationViewExtension/* Updated to handle CPython to PythonNet3 migration
src/Libraries/PythonNodeModels* Updated default engine and added migration UI elements
src/DynamoCoreWpf/* Added UI support for engine change notifications
src/DynamoCore.sln Removed DSCPython project references
extern/PythonNet3Engine/* Added new built-in package files
Files not reviewed (4)
  • src/DynamoCoreWpf/Properties/Resources.Designer.cs: Language not supported
  • src/Libraries/DSCPython/Properties/Resources.Designer.cs: Language not supported
  • src/Libraries/PythonNodeModels/Properties/Resources.Designer.cs: Language not supported
  • src/PythonMigrationViewExtension/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (5)

@zeusongit zeusongit requested a review from mjkkirschner October 8, 2025 17:46
@zeusongit zeusongit requested review from a team and twastvedt October 8, 2025 17:46
@@ -0,0 +1,317 @@
{
"runtimeTarget": {
Copy link
Member

@mjkkirschner mjkkirschner Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twastvedt are these deps.json files part of the package? Do you know if their inclusion actually makes a difference to how the package is loaded?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deps.json files seem to be a standard part of .NET core output now. Everything I turn up online says they should be included, though there's little MS documentation that I can find. But I haven't done any tests to see what happens if you leave them out. I'd suggest they should be included unless we find problems with having them in.

@@ -0,0 +1,15 @@
<?xml version="1.0"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not seem valuable to include.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove in #16548

Copy link
Member

@mjkkirschner mjkkirschner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the changes you have made to the migrator / tests csproj files are the best way forward. I'd like to understand what you were seeing that made you think referencing the binary from the bin folder was required?

Just looking at it without building anything myself ;) - I would:

  1. reference the binary from extern.
  2. make sure the binary does not get copied during the build to the dynamo output path - because it's already going to be copied by the copy step that is added to copy the entire package.

Also - we need to move that copy step to a project that is built during a core only build.

Last I don't understand the changes that have been made to the test package - but I don't really remember what was in there in the first place.

public bool ShowTabsAndSpacesInScriptEditor { get; set; }

/// <summary>
/// This defines if user wants to see the CPython3 update prompt.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this needs a super specific name or comment - because I could easily get this confused with our previous migration to Cpython3 from Ironpython2.

[JsonIgnore]
public bool ShowCPythonNotifications
{
get => enableCPythonNotifications;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of weird pattern? Why not just make this an auto property?

<Target Name="AfterBuildOps" AfterTargets="Build">
<ItemGroup>
<ExternTuneUpPkg Include="$(SolutionDir)..\extern\TuneUp\**\*.*" />
<ExternPythonNet3Pkg Include="$(SolutionDir)..\extern\PythonNet3Engine\**\*.*" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copy step should not be part of this wpf project, it should be party of Dynamo Core csproj -or some other csproj that is guaranteed to be part of a core only build so that even the DynamoCore non WPF sln will actually copy the files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood, dlls from \extern are not needed. DynamoCore copies the files from the NuGet now

/// </summary>
/// <param name="content">The target content to display.</param>
/// <param name="stayOpen">boolean indicates if the popup will stay open until user dismiss it.</param>
/// TODO: Make this API out of guide manager to a more generic place
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the summary / params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you. will push in #16548

Style="{StaticResource CustomRichTextBoxStyle}">
</localui:CustomRichTextBox>

<!-- Checkbox -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this effect other dynamo message box dialogs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the checkbox is collapsed by default. Only one call turns it visible.


CurrentWorkspace.UndoRecorder.RecordModificationForUndo(node);
node.EngineName = PythonEngineManager.PythonNet3EngineName;
node.OnNodeModified();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so upgrading nodes will also run them?

</PropertyGroup>
<ItemGroup>
<Reference Include="Python.Runtime">
<HintPath>..\..\bin\AnyCPU\$(Configuration)\Built-In Packages\packages\PythonNet3Engine\extra\Python.Runtime.dll</HintPath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this does not look correct. This project cannot rely on a reference to a file in the bin folder that won't exist until after a build.

Reference the binary in the one in the extern folder and mark it private false so it does not get copied to the dynamo output path.
If it's getting copied anyway, then you need to inspect the debug output to see why.

Why do you think you need to reference this binary from this location?

<HintPath>..\..\..\extern\Python\Python.Runtime.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Reference Include="DSPythonNet3">
<HintPath>..\..\..\bin\AnyCPU\$(Configuration)\Built-In Packages\packages\PythonNet3Engine\extra\DSPythonNet3.dll</HintPath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - this is not going to work / be reliable.

@@ -0,0 +1,14 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should revert this file.

@@ -0,0 +1,4 @@
<ExtensionDefinition>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have you added a copy of the ironPython package to the tests, did it already exist here?

@ivaylo-matov
Copy link
Contributor Author

I don't think the changes you have made to the migrator / tests csproj files are the best way forward. I'd like to understand what you were seeing that made you think referencing the binary from the bin folder was required?

Just looking at it without building anything myself ;) - I would:

  1. reference the binary from extern.
  2. make sure the binary does not get copied during the build to the dynamo output path - because it's already going to be copied by the copy step that is added to copy the entire package.

Also - we need to move that copy step to a project that is built during a core only build.

Last I don't understand the changes that have been made to the test package - but I don't really remember what was in there in the first place.

@mjkkirschner thanks for the comments - super helpful.

I originally referenced the binaries from \bin because at the time I thought those were the ones Dynamo would use at runtime. I see now that was the wrong approach for compile-time references; \extern is the right source.

@zeusongit has provided a NuGet for the PythonNet3 engine. With that in place we no longer need the \extern\Python or \extern\PythonNet3Engine folders. I’ll add the NuGet to DynamoCore so the package is copied into the Built-In Packages folder at build time. For the migrator I’ll reference Python.Runtime via NuGet (compile-time only) and keep it engine-agnostic. In DynamoPythonTests I’ll reference the engine NuGet as well; at runtime the tests will load DSPythonNet3 from the Built-In Packages folder via a small one-time resolver. Please correct me if any of that sounds wrong.

Regarding the test package: PackageDependencyTests need a second package we can load to flip a few Python nodes to a different engine and verify behavior. When CPython was the default, we used the PythonNet3 package for that role. Now that PythonNet3 is the default, I need to replace that test package with something else. I’ve reviewed the new files I added for this purpose and will remove anything unnecessary.

Thanks again for the review. I’ll respond to a few comments here, and now that the way forward is clear to me I’ll address all your points and push the updates to #16548. Hope that's okay.

ivaylo-matov added a commit to ivaylo-matov/Dynamo that referenced this pull request Oct 12, 2025
@zeusongit zeusongit closed this Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants