-
Notifications
You must be signed in to change notification settings - Fork 668
DYN-9388: Draft - New PythonNet3 engine #16582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DYN-9388: Draft - New PythonNet3 engine #16582
Conversation
This reverts commit 0389294.
…kage-does-not-load
cpython still present but does not load
…com/ivaylo-matov/Dynamo into DYN-9388-Net3-package-does-not-load
CPythonClassCanBeReturnedAndSafelyDisposedInDownStreamNode
testing stuff CPythonClassCanBeReturnedAndSafelyDisposedInDownStreamNode few test fixed
…ithub.com/ivaylo-matov/Dynamo into DYN-9388-Net3-package-does-not-load-TESTS
There was a problem hiding this 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
There was a problem hiding this 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)
| @@ -0,0 +1,317 @@ | |||
| { | |||
| "runtimeTarget": { | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"?> | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove in #16548
There was a problem hiding this 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:
- reference the binary from extern.
- 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. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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\**\*.*" /> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the summary / params.
There was a problem hiding this comment.
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 --> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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 @@ | |||
| { | |||
There was a problem hiding this comment.
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> | |||
There was a problem hiding this comment.
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?
@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. |
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:
srclogic: Implemented new functionality (identical to DYN-9388 Make PythonNet3 default python engine as built-in package #16548)Current status:
Most Python tests pass with this approach; a few are still failing (I’ll tale a look those now). Please confirm if:
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