From 2b6b30191a8b3279baf465363fec286360db3b34 Mon Sep 17 00:00:00 2001 From: "binny@vip.163.com" Date: Sat, 17 May 2025 00:17:50 +0900 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B0=20net9.0=EF=BC=8C?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E6=B5=8B=E8=AF=95=E8=B7=B3=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pythonnet.sln | 31 +++++------ src/embed_tests/Python.EmbeddingTest.csproj | 2 +- src/perf_tests/Python.PerformanceTests.csproj | 28 +++++----- .../Python.PythonTestsRunner.csproj | 12 ++--- src/runtime/Loader.cs | 2 +- src/runtime/Python.Runtime.csproj | 51 +++++++++++++++---- src/runtime/Runtime.cs | 2 + .../StateSerialization/NoopFormatter.cs | 1 + src/runtime/StateSerialization/RuntimeData.cs | 1 + src/testing/Python.Test.csproj | 18 ++++++- tests/domain_tests/App.config | 7 +-- .../Python.DomainReloadTests.csproj | 13 +---- tests/domain_tests/TestRunner.cs | 10 +++- 13 files changed, 107 insertions(+), 71 deletions(-) diff --git a/pythonnet.sln b/pythonnet.sln index cf684c0e1..b7f6e9c98 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -19,8 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F CHANGELOG.md = CHANGELOG.md LICENSE = LICENSE README.rst = README.rst - version.txt = version.txt shell.nix = shell.nix + version.txt = version.txt EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI", "CI", "{D301657F-5EAF-4534-B280-B858D651B2E5}" @@ -47,6 +47,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{142A6752 Directory.Build.props = Directory.Build.props EndProjectSection EndProject +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "TestCSharpParser", "..\BinnyWorkGit\PythonTools\Crack\Dotnet\TestCSharpParser.pyproj", "{84D84D18-F89C-4075-BEA7-83123F030F11}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -78,24 +80,6 @@ Global {4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x64.Build.0 = Debug|Any CPU {4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU {4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x86.Build.0 = Debug|Any CPU - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|Any CPU.ActiveCfg = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|Any CPU.Build.0 = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|x64.ActiveCfg = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|x64.Build.0 = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|x86.ActiveCfg = Debug|x86 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|x86.Build.0 = Debug|x86 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|Any CPU.ActiveCfg = Release|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|Any CPU.Build.0 = Release|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x64.ActiveCfg = Release|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x64.Build.0 = Release|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x86.ActiveCfg = Release|x86 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x86.Build.0 = Release|x86 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|Any CPU.ActiveCfg = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|Any CPU.Build.0 = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x64.ActiveCfg = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x64.Build.0 = Debug|x64 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x86.ActiveCfg = Debug|x86 - {E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x86.Build.0 = Debug|x86 {819E089B-4770-400E-93C6-4F7A35F0EA12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {819E089B-4770-400E-93C6-4F7A35F0EA12}.Debug|Any CPU.Build.0 = Debug|Any CPU {819E089B-4770-400E-93C6-4F7A35F0EA12}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -186,6 +170,15 @@ Global {35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x64.Build.0 = Debug|Any CPU {35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU {35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x86.Build.0 = Debug|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.Debug|x64.ActiveCfg = Debug|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.Debug|x86.ActiveCfg = Debug|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.Release|x64.ActiveCfg = Release|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.Release|x86.ActiveCfg = Release|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.TraceAlloc|Any CPU.ActiveCfg = Release|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.TraceAlloc|x64.ActiveCfg = Release|Any CPU + {84D84D18-F89C-4075-BEA7-83123F030F11}.TraceAlloc|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/embed_tests/Python.EmbeddingTest.csproj b/src/embed_tests/Python.EmbeddingTest.csproj index 4993994d3..2a7fc2fce 100644 --- a/src/embed_tests/Python.EmbeddingTest.csproj +++ b/src/embed_tests/Python.EmbeddingTest.csproj @@ -1,7 +1,7 @@ - net472;net6.0 + net9.0 ..\pythonnet.snk true diff --git a/src/perf_tests/Python.PerformanceTests.csproj b/src/perf_tests/Python.PerformanceTests.csproj index bde07ecab..581306cae 100644 --- a/src/perf_tests/Python.PerformanceTests.csproj +++ b/src/perf_tests/Python.PerformanceTests.csproj @@ -1,24 +1,22 @@ - + - net472 + net9.0 false x64 x64 - - - PreserveNewest - - + + 0 + + - - - false - - + + 0 + + @@ -34,8 +32,12 @@ + + + + - + diff --git a/src/python_tests_runner/Python.PythonTestsRunner.csproj b/src/python_tests_runner/Python.PythonTestsRunner.csproj index 63981c424..86a36ce33 100644 --- a/src/python_tests_runner/Python.PythonTestsRunner.csproj +++ b/src/python_tests_runner/Python.PythonTestsRunner.csproj @@ -1,14 +1,9 @@ - net472;net6.0 + net9.0 - - - - - @@ -23,4 +18,9 @@ + + + + + diff --git a/src/runtime/Loader.cs b/src/runtime/Loader.cs index c0e964abc..56f35c6be 100644 --- a/src/runtime/Loader.cs +++ b/src/runtime/Loader.cs @@ -59,5 +59,5 @@ public unsafe static int Shutdown(IntPtr data, int size) return 0; } - } + } } diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj index 0a7f58a3c..8fc552466 100644 --- a/src/runtime/Python.Runtime.csproj +++ b/src/runtime/Python.Runtime.csproj @@ -1,6 +1,6 @@ - + - netstandard2.0 + net9.0 AnyCPU 10.0 Python.Runtime @@ -32,20 +32,55 @@ true Debug;Release;TraceAlloc + + D:\Linux\anaconda3\envs\python312\Lib\site-packages\pythonnet\runtime + + False + + True + + D:\Test + + critical $(DefineConstants);TRACE_ALLOC - - ..\..\pythonnet\runtime - false + + 0 + False + + + + 2 + False + $(DefineConstants);DEBUG + + + + 0 + + + + 2 + + + + 0 + + + + 2 + + + @@ -57,10 +92,4 @@ - - - - - - diff --git a/src/runtime/Runtime.cs b/src/runtime/Runtime.cs index c8f022860..b4ffc46af 100644 --- a/src/runtime/Runtime.cs +++ b/src/runtime/Runtime.cs @@ -26,6 +26,8 @@ public static string? PythonDLL if (_isInitialized) throw new InvalidOperationException("This property must be set before runtime is initialized"); _PythonDll = value; + if (value == null) + _PythonDll = GetDefaultDllName(); } } diff --git a/src/runtime/StateSerialization/NoopFormatter.cs b/src/runtime/StateSerialization/NoopFormatter.cs index f05b7ebb2..59852e72b 100644 --- a/src/runtime/StateSerialization/NoopFormatter.cs +++ b/src/runtime/StateSerialization/NoopFormatter.cs @@ -1,3 +1,4 @@ +#pragma warning disable SYSLIB0011 using System; using System.IO; using System.Runtime.Serialization; diff --git a/src/runtime/StateSerialization/RuntimeData.cs b/src/runtime/StateSerialization/RuntimeData.cs index 8eda9ce0b..1e6b29ac0 100644 --- a/src/runtime/StateSerialization/RuntimeData.cs +++ b/src/runtime/StateSerialization/RuntimeData.cs @@ -1,3 +1,4 @@ +#pragma warning disable SYSLIB0011 using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/testing/Python.Test.csproj b/src/testing/Python.Test.csproj index 3adc5c0c6..a353d4f4e 100644 --- a/src/testing/Python.Test.csproj +++ b/src/testing/Python.Test.csproj @@ -1,13 +1,29 @@ - netstandard2.0;net6.0 + net9.0 true true ..\pythonnet.snk true IDE0051;IDE0060 + D:\Linux\anaconda3\Lib\site-packages\pythonnet-3.1.0.dev0-py3.11.egg\pythonnet\runtime + + + 0 + + + 0 + + + 0 + + + 0 + + + diff --git a/tests/domain_tests/App.config b/tests/domain_tests/App.config index 56efbc7b5..17ed4fd9f 100644 --- a/tests/domain_tests/App.config +++ b/tests/domain_tests/App.config @@ -1,6 +1 @@ - - - - - - \ No newline at end of file + diff --git a/tests/domain_tests/Python.DomainReloadTests.csproj b/tests/domain_tests/Python.DomainReloadTests.csproj index 9cb61c6f4..10e8c8034 100644 --- a/tests/domain_tests/Python.DomainReloadTests.csproj +++ b/tests/domain_tests/Python.DomainReloadTests.csproj @@ -1,26 +1,17 @@ - net472 + net9.0 bin\ Exe - - - - - - + - - - - diff --git a/tests/domain_tests/TestRunner.cs b/tests/domain_tests/TestRunner.cs index bbee81b3d..2715ab854 100644 --- a/tests/domain_tests/TestRunner.cs +++ b/tests/domain_tests/TestRunner.cs @@ -1,11 +1,12 @@ // We can't refer to or use Python.Runtime here. // We want it to be loaded only inside the subdomains + using System; +using System.Reflection; using Microsoft.CSharp; using System.CodeDom.Compiler; using System.IO; using System.Linq; - namespace Python.DomainReloadTests { /// @@ -1454,6 +1455,7 @@ static AppDomain CreateDomain(string name) // path from the CWD (namely, 'bin'). // See https://stackoverflow.com/questions/24760543/createinstanceandunwrap-in-another-domain var currentDomain = AppDomain.CurrentDomain; + /* var domainsetup = new AppDomainSetup() { ApplicationBase = TestPath, @@ -1461,11 +1463,15 @@ static AppDomain CreateDomain(string name) LoaderOptimization = LoaderOptimization.SingleDomain, PrivateBinPath = "." }; + var domain = AppDomain.CreateDomain( $"My Domain {name}", currentDomain.Evidence, domainsetup); - + */ + + var domain = AppDomain.CreateDomain( + $"My Domain {name}"); return domain; }