Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3069fe4

Browse files
author
dse
committed
Python.Runtime.dll now targets NetStandard2.0 inplace of NetCoreApp 2.0
1 parent dac5a96 commit 3069fe4

File tree

10 files changed

+32
-27
lines changed

10 files changed

+32
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
88
## [unreleased][]
99

1010
### Added
11-
- Added support for embedding python into dotnet core 2.0 (NetCoreApp2.0)
11+
- Added support for embedding python into dotnet core 2.0 (NetStandard 2.0)
1212
- Added new build system (pythonnet.15.sln) based on dotnetcore-sdk/xplat(crossplatform msbuild).
1313
Currently there two side-by-side build systems that produces the same output (net40) from the same sources.
1414
After a some transition time, current (mono/ msbuild 14.0) build system will be removed.

pythonnet.15.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
33
VisualStudioVersion = 15.0.26730.3
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src\runtime\Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src/runtime/Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}"
66
EndProject
7-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src\embed_tests\Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}"
7+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src/embed_tests/Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}"
88
EndProject
9-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src\clrmodule\clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}"
9+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src/clrmodule/clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}"
1010
EndProject
11-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src\console\Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}"
11+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src/console/Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}"
1212
EndProject
13-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src\testing\Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}"
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src/testing/Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}"
1414
EndProject
1515
Global
1616
GlobalSection(SolutionConfigurationPlatforms) = preSolution

setup.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,8 @@ def build_extension(self, ext):
257257

258258
subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell)
259259
subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
260-
if DEVTOOLS == "MsDev15":
261-
subprocess.check_call(" ".join(cmd + ["/t:Console_15:publish;Python_EmbeddingTest_15:publish", "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell)
262-
elif DEVTOOLS == "dotnet":
263-
subprocess.check_call(" ".join(cmd + ["/t:publish", "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell)
264-
260+
if DEVTOOLS == "MsDev15" or DEVTOOLS == "dotnet":
261+
subprocess.check_call(" ".join(cmd + ['"/t:Console_15:publish;Python_EmbeddingTest_15:publish"', "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell)
265262
if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet":
266263
self._build_monoclr()
267264

src/embed_tests/pyimport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void SetUp()
3030
/* Append the tests directory to sys.path
3131
* using reflection to circumvent the private
3232
* modifiers placed on most Runtime methods. */
33-
#if NETCOREAPP
33+
#if NETSTANDARD
3434
const string s = "../../fixtures";
3535
#else
3636
const string s = "../fixtures";

src/runtime/Python.Runtime.15.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
33
<PropertyGroup>
4-
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
4+
<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
55
<Platforms>AnyCPU</Platforms>
66
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
77
<AssetTargetFallback Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">net45</AssetTargetFallback>
@@ -29,7 +29,7 @@
2929
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
3030
<BaseDefineConstants>XPLAT</BaseDefineConstants>
3131
<DefineConstants>$(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants);</DefineConstants>
32-
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.0'">$(DefineConstants);NETCOREAPP</DefineConstants>
32+
<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">$(DefineConstants);NETSTANDARD</DefineConstants>
3333
<FrameworkPathOverride Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">$(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\</FrameworkPathOverride>
3434
</PropertyGroup>
3535

@@ -101,10 +101,9 @@
101101
</EmbeddedResource>
102102
</ItemGroup>
103103

104-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
105-
<PackageReference Include="System.Security.Permissions">
106-
<Version>4.4.0</Version>
107-
</PackageReference>
104+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
105+
<PackageReference Include="System.Security.Permissions" Version="4.4.0" />
106+
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
108107
</ItemGroup>
109108

110109
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">

src/runtime/nativecall.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Python.Runtime
2323
/// </summary>
2424
internal class NativeCall
2525
{
26-
#if NETCOREAPP
26+
#if NETSTANDARD
2727
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2828
private delegate void Void_1_Delegate(IntPtr a1);
2929

src/runtime/polyfill/ReflectionPolifills.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44

55
namespace Python.Runtime
66
{
7+
#if NETSTANDARD
78
public static class ReflectionPolifills
89
{
9-
#if NETCOREAPP
1010
public static AssemblyBuilder DefineDynamicAssembly(this AppDomain appDomain, AssemblyName assemblyName, AssemblyBuilderAccess assemblyBuilderAccess)
1111
{
1212
return AssemblyBuilder.DefineDynamicAssembly(assemblyName, assemblyBuilderAccess);
1313
}
14-
#endif
14+
15+
public static Type CreateType(this TypeBuilder typeBuilder)
16+
{
17+
return typeBuilder.GetTypeInfo().GetType();
18+
}
1519
}
20+
#endif
1621
}

src/runtime/runtime.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Python.Runtime
99
internal static class NativeMethods
1010
{
1111
#if MONO_LINUX || MONO_OSX
12-
#if NETCOREAPP
12+
#if NETSTANDARD
1313
private static int RTLD_NOW = 0x2;
1414
#if MONO_LINUX
1515
private static int RTLD_GLOBAL = 0x100;
@@ -181,7 +181,7 @@ public class Runtime
181181

182182
public static readonly string PythonDLL = _PythonDll;
183183

184-
#if PYTHON_WITHOUT_ENABLE_SHARED && !NETCOREAPP
184+
#if PYTHON_WITHOUT_ENABLE_SHARED && !NETSTANDARD
185185
internal const string _PythonDll = "__Internal";
186186
#else
187187
internal const string _PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc;
@@ -522,7 +522,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
522522
/// </summary>
523523
internal static unsafe void XIncref(IntPtr op)
524524
{
525-
#if PYTHON_WITH_PYDEBUG || NETCOREAPP
525+
#if PYTHON_WITH_PYDEBUG || NETSTANDARD
526526
Py_IncRef(op);
527527
return;
528528
#else
@@ -543,7 +543,7 @@ internal static unsafe void XIncref(IntPtr op)
543543

544544
internal static unsafe void XDecref(IntPtr op)
545545
{
546-
#if PYTHON_WITH_PYDEBUG || NETCOREAPP
546+
#if PYTHON_WITH_PYDEBUG || NETSTANDARD
547547
Py_DecRef(op);
548548
return;
549549
#else

src/testing/Python.Test.15.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
33
<PropertyGroup>
4-
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
4+
<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
55
<Platforms>x64;x86</Platforms>
66
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
77
<AssemblyName>Python.Test</AssemblyName>
@@ -77,7 +77,11 @@
7777
</ItemGroup>
7878

7979
<ItemGroup>
80-
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj"/>
80+
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
81+
</ItemGroup>
82+
83+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
84+
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
8185
</ItemGroup>
8286

8387
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

0 commit comments

Comments
 (0)