-
Notifications
You must be signed in to change notification settings - Fork 668
DYN-9388 Make PythonNet3 default python engine as built-in package #16548
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 Make PythonNet3 default python engine as built-in package #16548
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
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 makes PythonNet3 the default Python engine as a built-in package, replacing CPython3. It provides automatic migration of existing CPython nodes to PythonNet3 with user notifications and adds preferences to control these notifications.
Key changes:
- Switches default Python engine from CPython3 to PythonNet3 across the codebase
- Implements automatic node migration with toast notifications and dialog boxes
- Adds user preference controls for hiding migration notifications
Reviewed Changes
Copilot reviewed 66 out of 77 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/PythonMigrationViewExtension/PythonMigrationViewExtension.cs | Adds CPython to PythonNet3 migration logic with notifications and automatic node upgrading |
| src/NodeServices/PythonServices.cs | Updates default engine references and removes automatic CPython loading |
| src/Libraries/PythonNodeModels/PythonNode.cs | Changes default engine from CPython3 to PythonNet3 and adds ShowAutoUpgradedBar property |
| src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs | Implements UI handlers for Python engine change notifications and dialogs |
| src/DynamoCore/Configuration/PreferenceSettings.cs | Adds HideCPython3Notifications preference setting |
| extern/PythonNet3Engine/ | Adds PythonNet3 engine as built-in package with all necessary configuration files |
Files not reviewed (3)
- src/DynamoCoreWpf/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)
| <data name="ResetCPythonButtonText" xml:space="preserve"> | ||
| <value>Reimposta CPython</value> | ||
| <data name="ResetPythonNet3ButtonText" xml:space="preserve"> | ||
| <value>Reimposta PythonNet3</value> |
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.
You don't need to update the strings for all locale(s) they are updated by some automation we have setup afterwards. We just need to update them in Resources.Designer.cs and Resources.resx 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.
reverted the changes now
We can add them to the excluded files list here: https://github.com/DynamoDS/Dynamo/blob/master/.github/scripts/check_file_version.ps1#L15 |
68456d0 to
e5f81c1
Compare
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
Copilot reviewed 67 out of 78 changed files in this pull request and generated no new comments.
Files not reviewed (3)
- src/DynamoCoreWpf/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)
…com/ivaylo-matov/Dynamo into DYN-9388-Net3-package-does-not-load
|
@twastvedt @mjkkirschner I think this is ready for another look, the changes from other PR as well as the Nuget is merged in this |
|
@avidit @QilongTang The self serve job fails repeatedly with instance being killed, cannot figure out if tests are failing/causing it or something else |
src/DynamoCore/DynamoCore.csproj
Outdated
| <DllExtra Include="$(LibDir)DSPythonNet3Extension_ExtensionDefinition.xml" Condition="Exists('$(LibDir)DSPythonNet3Extension_ExtensionDefinition.xml')" /> | ||
| </ItemGroup> | ||
| <Copy SourceFiles="@(DllExtra)" DestinationFolder="$(DestExtra)" SkipUnchangedFiles="True" /> | ||
| </Target> |
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.
What's the reasoning for needing this to know so much about the exact files it's copying, and where they go? Why can't the package created by the PythonNet3 engine repo come formatted correctly, with all the files in a single known folder ready to copy into Built-in packages? That way DynamoCore wouldn't need to know about the inner workings of the Python package, and thus need to be updated if the package structure changes.
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.
yeah pretty much agree, the less code here the better...
- it appears you are just copying everything from bin, so just copy the contents of lib, are you excluding something?
- is there not a net10 version of pythonNet? Then you could do
Lib\$(TargetFramework)
| catch(Exception ex) | ||
|
|
||
| // Set PythonNet3 as the default engine if it is isntalled and no other valid engine is set as default | ||
| var eng = e.NewItems[0] as PythonServices.PythonEngine; |
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.
is it a problem that this might get fired at some time in the future when a user installs a package that includes a python engine?
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.
You are right, I postponed this for after all engines are loaded.
| /// <returns></returns> | ||
| internal static string MigrateCode(string code) | ||
| { | ||
| DSCPython.CPythonEvaluator.InstallPython(); |
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.
how does this work with the new package - where / how does the runtime get installed?
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.
PythonNet3 bootstraps the runtime itself and wires the engine up when the package loads.
On startup PackageLoader loads built-in packages. After a package is loaded it calls LoadPythonEngine() to discover and register engine classes from those assemblies.
| { | ||
| PythonEngine.ReleaseLock(gs); | ||
| } | ||
| finally { } |
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.
not really useful...
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.
Removed now.
Switched to using (Py.GIL()) because pythonnet3 removed AcquireLock/ReleaseLock and we must explicitly hold the GIL. Also PythonEngine.BeginAllowThreads() because that’s for releasing the GIL during long .NET-only work.
|
@ivaylo-matov a few comments and one potentially bigger change: Also I ran into a problem running IronPython3 package under net10 - did you see the same issue with IronPython2? |
Done - zipped the loose package files and added an MSBuild target in DynamoPythonTests.csproj to unzip during test builds. Also added a local .gitignore in to whitelist PythonEnginePackage.zip. Hope that's okay. |
maybe you can try running the same test script locally and see if the test runner crashes? |
zeusongit
left a comment
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.
@ivaylo-matov thank you for the updates, I have been testing the PR, and it seems to be in a good state, I will merge this now so that QAs can push testing further.
@mjkkirschner @twastvedt thank you for the review, if their are some outstanding comments, they will be addressed in separate PRs, however I think most of them have already been addressed, free to take another look.
…ynamoDS#16548) (cherry picked from commit 38f5741)


Purpose
PR in response to DYN-9388.
Declarations
Check these if you believe they are true
Release Notes
Make PythonNet3 default python engine as built-in package
Reviewers
@zeusongit
@DynamoDS/eidos
FYIs
@dnenov
@achintyabhat