Skip to content
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-4800: Bump Python version to 3.9.12 #12815

Merged
merged 8 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified extern/Python/Python.Included.dll
Binary file not shown.
Binary file modified extern/Python/Python.Runtime.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Libraries/DSCPython/CPythonEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static object EvaluatePythonScript(
/// NOTE: Calling SetupPython multiple times will add the install location to the path many times,
/// potentially causing the environment variable to overflow.
/// </summary>
private static void InstallPython()
internal static void InstallPython()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it internal. Would it be OK to make this public?

Copy link
Member

Choose a reason for hiding this comment

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

since it has a side effect that is potentially dangerous I'd prefer if extensions could not call it.

{
if (!isPythonInstalled)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/DSCPython/DSCPython.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<AssemblyName>DSCPython</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Reference Include="Python.Included, Version=2.5.1.2374, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Python.Included, Version=2.5.2.4265, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\extern\Python\Python.Included.dll</HintPath>
</Reference>
<Reference Include="Python.Runtime, Version=2.5.1.2374, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Python.Runtime, Version=2.5.2.4265, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\extern\Python\Python.Runtime.dll</HintPath>
</Reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import clr

private object ExecutePythonScriptCode(string code)
{
Python.Included.Installer.SetupPython().Wait();
DSCPython.CPythonEvaluator.InstallPython();

if (!PythonEngine.IsInitialized)
{
Expand Down Expand Up @@ -376,6 +376,8 @@ public DSCPythonCodeCompletionProviderCore()
BasicVariableTypes.Add(Tuple.Create(LIST_VARIABLE, typeof(PyList)));
BasicVariableTypes.Add(Tuple.Create(DICT_VARIABLE, typeof(PyDict)));

DSCPython.CPythonEvaluator.InstallPython();

if (!PythonEngine.IsInitialized)
{
PythonEngine.Initialize();
Expand Down
3 changes: 2 additions & 1 deletion src/Libraries/DSCPython/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f1541c2d-80a9-4fe7-8d9e-75a8b9ff3479")]
[assembly:InternalsVisibleTo("DynamoPythonTests")]
[assembly: InternalsVisibleTo("PythonMigrationViewExtension")]
[assembly: InternalsVisibleTo("DynamoPythonTests")]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using Python.Included;
using Python.Runtime;

namespace Dynamo.PythonMigration.MigrationAssistant
Expand All @@ -19,7 +18,7 @@ internal static class ScriptMigrator
/// <returns></returns>
internal static string MigrateCode(string code)
{
InstallPython();
DSCPython.CPythonEvaluator.InstallPython();

if (!PythonEngine.IsInitialized)
{
Expand Down Expand Up @@ -70,21 +69,6 @@ internal static string MigrateCode(string code)
}
}

private static bool isPythonInstalled = false;
/// <summary>
/// Makes sure Python is installed on the system and it's location added to the path.
/// NOTE: Calling SetupPython multiple times will add the install location to the path many times,
/// potentially causing the environment variable to overflow.
/// </summary>
private static void InstallPython()
{
if (!isPythonInstalled)
{
Python.Included.Installer.SetupPythonSync();
isPythonInstalled = true;
}
}

private static string Get2To3MigrationScript(Assembly asm)
{
return GetEmbeddedScript(asm, "Dynamo.PythonMigration.MigrationAssistant.migrate_2to3.py");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@
<AssemblyName>PythonMigrationViewExtension</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DiffPlex" Version="1.6.3" CopyMetaData="true"/>
<PackageReference Include="DiffPlex" Version="1.6.3" CopyMetaData="true" />
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" />
<Reference Include="PresentationCore">
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework">
<Private>False</Private>
</Reference>
<Reference Include="Python.Included, Version=2.5.1.2374, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\extern\Python\Python.Included.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Python.Runtime, Version=2.5.1.2374, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Python.Runtime, Version=2.5.2.4265, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\extern\Python\Python.Runtime.dll</HintPath>
<Private>False</Private>
Expand All @@ -49,6 +44,7 @@
<Name>DynamoCore</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\Libraries\DSCPython\DSCPython.csproj" />
<ProjectReference Include="..\Libraries\PythonNodeModels\PythonNodeModels.csproj">
<Project>{8872ca17-c10d-43b9-8393-5c5a57065eb0}</Project>
<Name>PythonNodeModels</Name>
Expand Down
4 changes: 2 additions & 2 deletions test/Libraries/DynamoPythonTests/CodeCompletionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void CanFindAllTypeImports()
[Category("UnitTests")]
public void CanFindDifferentTypesOfImportsAndLoad()
{
var str = "from itertools import *\nimport math\nfrom sys import callstats\n";
var str = "from itertools import *\nimport math\nfrom sys import exit\n";

var completionProvider = new DSCPythonCodeCompletionProviderCore();
try
Expand All @@ -339,7 +339,7 @@ public void CanFindDifferentTypesOfImportsAndLoad()
Assert.AreEqual(3, completionProvider.ImportedTypes.Count);
Assert.IsTrue(completionProvider.ScopeHasVariable("repeat"));
Assert.IsTrue(completionProvider.ScopeHasVariable("math"));
Assert.IsTrue(completionProvider.ScopeHasVariable("callstats"));
Assert.IsTrue(completionProvider.ScopeHasVariable("exit"));
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions test/Libraries/DynamoPythonTests/PythonEditTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public void PythonNodeEnginePropertyChangeTest()
}
else if (pythonEngine == PythonEngineManager.CPython3EngineName)
{
Assert.AreEqual("3.8.10", nodeValue);
Assert.AreEqual("3.9.12", nodeValue);
}
}
}
Expand Down Expand Up @@ -439,11 +439,11 @@ public void TestWorkspaceWithMultiplePythonEngines()

UpdatePythonEngineAndRun(pynode1, PythonEngineManager.CPython3EngineName);
Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
AssertPreviewValue(pynode1.GUID.ToString("N"), "3.8.10");
AssertPreviewValue(pynode1.GUID.ToString("N"), "3.9.12");

UpdatePythonEngineAndRun(pynode2, PythonEngineManager.CPython3EngineName);
Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
AssertPreviewValue(pynode2.GUID.ToString("N"), new List<string> { "3.8.10", "3.8.10" });
AssertPreviewValue(pynode2.GUID.ToString("N"), new List<string> { "3.9.12", "3.9.12" });
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion test/Libraries/IronPythonTests/IronPythonTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Python.Runtime, Version=2.5.1.7, Culture=neutral, PublicKeyToken=null" />
<Reference Include="Python.Runtime, Version=2.5.2.4265, Culture=neutral, PublicKeyToken=null" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
Expand Down
6 changes: 3 additions & 3 deletions test/Libraries/IronPythonTests/PythonEditTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public void PythonNodeEnginePropertyChangeTest()
}
else if (pythonEngine == PythonEngineVersion.CPython3)
{
Assert.AreEqual(nodeValue, "3.8.10");
Assert.AreEqual(nodeValue, "3.9.12");
}
}
}
Expand Down Expand Up @@ -477,11 +477,11 @@ public void TestWorkspaceWithMultiplePythonEngines()

UpdatePythonEngineAndRun(pynode1, PythonEngineVersion.CPython3);
Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
AssertPreviewValue(pythonNode2GUID, new List<string> { "3.8.10", "2.7.9" });
AssertPreviewValue(pythonNode2GUID, new List<string> { "3.9.12", "2.7.9" });

UpdatePythonEngineAndRun(pynode2, PythonEngineVersion.CPython3);
Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
AssertPreviewValue(pythonNode2GUID, new List<string> { "3.8.10", "3.8.10" });
AssertPreviewValue(pythonNode2GUID, new List<string> { "3.9.12", "3.9.12" });

UpdateEngineAndRunForAllPythonNodes(pythonNodes, PythonEngineVersion.IronPython2);
Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ public void WorkspaceWithMultiplePythonEnginesUpdatesCorrectlyViaContextHandler(
SetEngineViaContextMenu(pynode1view, PythonEngineVersion.CPython3);

Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
Assert.AreEqual(new List<string> { "3.8.10", "2.7.9" }, pynode2.CachedValue.GetElements().Select(x => x.Data));
Assert.AreEqual(new List<string> { "3.9.12", "2.7.9" }, pynode2.CachedValue.GetElements().Select(x => x.Data));

SetEngineViaContextMenu(pynode2view, PythonEngineVersion.CPython3);

Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
Assert.AreEqual(new List<string> { "3.8.10", "3.8.10" }, pynode2.CachedValue.GetElements().Select(x => x.Data));
Assert.AreEqual(new List<string> { "3.9.12", "3.9.12" }, pynode2.CachedValue.GetElements().Select(x => x.Data));

SetEngineViaContextMenu(pynode1view, PythonEngineVersion.IronPython2);
SetEngineViaContextMenu(pynode2view, PythonEngineVersion.IronPython2);
Expand All @@ -482,10 +482,10 @@ public void WorkspaceWithMultiplePythonEnginesUpdatesCorrectlyViaContextHandler(
DispatcherUtil.DoEvents();

Model.CurrentWorkspace.Undo();
Assert.AreEqual(new List<string> { "2.7.9", "3.8.10" }, pynode2.CachedValue.GetElements().Select(x => x.Data));
Assert.AreEqual(new List<string> { "2.7.9", "3.9.12" }, pynode2.CachedValue.GetElements().Select(x => x.Data));
DispatcherUtil.DoEvents();
Model.CurrentWorkspace.Undo();
Assert.AreEqual(new List<string> { "3.8.10", "3.8.10" }, pynode2.CachedValue.GetElements().Select(x => x.Data));
Assert.AreEqual(new List<string> { "3.9.12", "3.9.12" }, pynode2.CachedValue.GetElements().Select(x => x.Data));
DispatcherUtil.DoEvents();

}
Expand Down