Skip to content

Commit eec5c37

Browse files
committed
upgrade Python.Runtime to netstandard2.0
1 parent f544adc commit eec5c37

File tree

4 files changed

+56
-200
lines changed

4 files changed

+56
-200
lines changed

pythonnet.sln

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 14
3-
VisualStudioVersion = 14.0.25420.1
2+
# Visual Studio Version 16
3+
VisualStudioVersion = 16.0.28803.452
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}"
66
EndProject
@@ -32,38 +32,38 @@ Global
3232
ReleaseWinPY3|x86 = ReleaseWinPY3|x86
3333
EndGlobalSection
3434
GlobalSection(ProjectConfigurationPlatforms) = postSolution
35-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.ActiveCfg = DebugMono|x64
36-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.Build.0 = DebugMono|x64
37-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.ActiveCfg = DebugMono|x86
38-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.Build.0 = DebugMono|x86
39-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64
40-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64
41-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86
42-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86
43-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.ActiveCfg = DebugWin|x64
44-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.Build.0 = DebugWin|x64
45-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.ActiveCfg = DebugWin|x86
46-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.Build.0 = DebugWin|x86
47-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64
48-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64
49-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86
50-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86
51-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64
52-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.Build.0 = ReleaseMono|x64
53-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86
54-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.Build.0 = ReleaseMono|x86
55-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64
56-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64
57-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86
58-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86
59-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64
60-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.Build.0 = ReleaseWin|x64
61-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86
62-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.Build.0 = ReleaseWin|x86
63-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64
64-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64
65-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86
66-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86
35+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.ActiveCfg = Debug|Any CPU
36+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.Build.0 = Debug|Any CPU
37+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.ActiveCfg = Debug|Any CPU
38+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.Build.0 = Debug|Any CPU
39+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.ActiveCfg = Debug|Any CPU
40+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.Build.0 = Debug|Any CPU
41+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.ActiveCfg = Debug|Any CPU
42+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.Build.0 = Debug|Any CPU
43+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.ActiveCfg = Debug|Any CPU
44+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.Build.0 = Debug|Any CPU
45+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.ActiveCfg = Debug|Any CPU
46+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.Build.0 = Debug|Any CPU
47+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.ActiveCfg = Debug|Any CPU
48+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.Build.0 = Debug|Any CPU
49+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.ActiveCfg = Debug|Any CPU
50+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.Build.0 = Debug|Any CPU
51+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.ActiveCfg = Release|Any CPU
52+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.Build.0 = Release|Any CPU
53+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.ActiveCfg = Release|Any CPU
54+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.Build.0 = Release|Any CPU
55+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.ActiveCfg = Release|Any CPU
56+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.Build.0 = Release|Any CPU
57+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.ActiveCfg = Release|Any CPU
58+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.Build.0 = Release|Any CPU
59+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.ActiveCfg = Release|Any CPU
60+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.Build.0 = Release|Any CPU
61+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.ActiveCfg = Release|Any CPU
62+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.Build.0 = Release|Any CPU
63+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.ActiveCfg = Release|Any CPU
64+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.Build.0 = Release|Any CPU
65+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.ActiveCfg = Release|Any CPU
66+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.Build.0 = Release|Any CPU
6767
{6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.ActiveCfg = DebugMono|x64
6868
{6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.Build.0 = DebugMono|x64
6969
{6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x86.ActiveCfg = DebugMono|x86
@@ -188,6 +188,9 @@ Global
188188
GlobalSection(SolutionProperties) = preSolution
189189
HideSolutionNode = FALSE
190190
EndGlobalSection
191+
GlobalSection(ExtensibilityGlobals) = postSolution
192+
SolutionGuid = {6EBD48BE-33F5-44AA-9006-850A23CAE8BF}
193+
EndGlobalSection
191194
GlobalSection(MonoDevelopProperties) = preSolution
192195
StartupItem = src\console\Console.csproj
193196
Policies = $0

src/runtime/Python.Runtime.csproj

Lines changed: 15 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,24 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProjectGuid>{097B4AC0-74E9-4C58-BCF8-C69746EC8271}</ProjectGuid>
7-
<OutputType>Library</OutputType>
8-
<AssemblyName>Python.Runtime</AssemblyName>
9-
<RootNamespace>Python.Runtime</RootNamespace>
10-
<DocumentationFile>bin\Python.Runtime.xml</DocumentationFile>
11-
<OutputPath>bin\</OutputPath>
12-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13-
<TargetFrameworkProfile />
14-
<NoWarn>1591</NoWarn>
15-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
16-
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
17-
<AppDesignerFolder>Properties</AppDesignerFolder>
18-
<LangVersion>6</LangVersion>
19-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
20-
<SignAssembly>false</SignAssembly>
21-
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
22-
</PropertyGroup>
23-
<!--We can relax binding to platform because code references no any platform dependent assemblies-->
24-
<!--This will allows to use any build of this assebly as a compile ref assebly-->
25-
<!--<PropertyGroup Condition=" '$(Platform)' == 'x86'">
26-
<PlatformTarget>x86</PlatformTarget>
27-
</PropertyGroup>
28-
<PropertyGroup Condition=" '$(Platform)' == 'x64'">
29-
<PlatformTarget>x64</PlatformTarget>
30-
</PropertyGroup>-->
31-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
32-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON2;PYTHON27;UCS4</DefineConstants>
33-
<Optimize>true</Optimize>
34-
<DebugType>pdbonly</DebugType>
35-
</PropertyGroup>
36-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
37-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS4</DefineConstants>
38-
<Optimize>true</Optimize>
39-
<DebugType>pdbonly</DebugType>
40-
</PropertyGroup>
41-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
42-
<DebugSymbols>true</DebugSymbols>
43-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON2;PYTHON27;UCS4;TRACE;DEBUG</DefineConstants>
44-
<Optimize>false</Optimize>
45-
<DebugType>full</DebugType>
46-
</PropertyGroup>
47-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
48-
<DebugSymbols>true</DebugSymbols>
49-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS4;TRACE;DEBUG</DefineConstants>
50-
<Optimize>false</Optimize>
51-
<DebugType>full</DebugType>
52-
</PropertyGroup>
53-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
54-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON2;PYTHON27;UCS2</DefineConstants>
55-
<Optimize>true</Optimize>
56-
<DebugType>pdbonly</DebugType>
57-
</PropertyGroup>
58-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
59-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS2</DefineConstants>
60-
<Optimize>true</Optimize>
61-
<DebugType>pdbonly</DebugType>
62-
</PropertyGroup>
63-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
64-
<DebugSymbols>true</DebugSymbols>
65-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON2;PYTHON27;UCS2;TRACE;DEBUG</DefineConstants>
66-
<Optimize>false</Optimize>
67-
<DebugType>full</DebugType>
4+
<TargetFramework>netstandard2.0</TargetFramework>
685
</PropertyGroup>
69-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
70-
<DebugSymbols>true</DebugSymbols>
71-
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON3;PYTHON37;UCS2;TRACE;DEBUG</DefineConstants>
72-
<Optimize>false</Optimize>
73-
<DebugType>full</DebugType>
6+
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
8+
<DefineConstants>DEBUG;TRACE;PYTHON3;PYTHON36;UCS2</DefineConstants>
9+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7410
</PropertyGroup>
11+
7512
<ItemGroup>
76-
<Reference Include="System" />
13+
<None Remove="resources\clr.py" />
7714
</ItemGroup>
15+
7816
<ItemGroup>
79-
<Compile Include="finalizer.cs" />
80-
<Compile Include="Properties\AssemblyInfo.cs" />
81-
<Compile Include="..\SharedAssemblyInfo.cs">
82-
<Link>Properties\SharedAssemblyInfo.cs</Link>
83-
</Compile>
84-
<Compile Include="arrayobject.cs" />
85-
<Compile Include="assemblymanager.cs" />
86-
<Compile Include="classderived.cs" />
87-
<Compile Include="classbase.cs" />
88-
<Compile Include="classmanager.cs" />
89-
<Compile Include="classobject.cs" />
90-
<Compile Include="clrobject.cs" />
91-
<Compile Include="codegenerator.cs" />
92-
<Compile Include="constructorbinder.cs" />
93-
<Compile Include="constructorbinding.cs" />
94-
<Compile Include="converter.cs" />
95-
<Compile Include="CustomMarshaler.cs" />
96-
<Compile Include="debughelper.cs" />
97-
<Compile Include="delegatemanager.cs" />
98-
<Compile Include="delegateobject.cs" />
99-
<Compile Include="eventbinding.cs" />
100-
<Compile Include="eventobject.cs" />
101-
<Compile Include="exceptions.cs" />
102-
<Compile Include="extensiontype.cs" />
103-
<Compile Include="fieldobject.cs" />
104-
<Compile Include="generictype.cs" />
105-
<Compile Include="genericutil.cs" />
106-
<Compile Include="importhook.cs" />
107-
<Compile Include="indexer.cs" />
108-
<Compile Include="interfaceobject.cs" />
109-
<Compile Include="interfaces.cs" />
110-
<Compile Include="interop.cs" />
111-
<Compile Include="iterator.cs" />
112-
<Compile Include="managedtype.cs" />
113-
<Compile Include="metatype.cs" />
114-
<Compile Include="methodbinder.cs" />
115-
<Compile Include="methodbinding.cs" />
116-
<Compile Include="methodobject.cs" />
117-
<Compile Include="methodwrapper.cs" />
118-
<Compile Include="modulefunctionobject.cs" />
119-
<Compile Include="moduleobject.cs" />
120-
<Compile Include="modulepropertyobject.cs" />
121-
<Compile Include="nativecall.cs" />
122-
<Compile Include="overload.cs" />
123-
<Compile Include="propertyobject.cs" />
124-
<Compile Include="pyansistring.cs" />
125-
<Compile Include="pydict.cs" />
126-
<Compile Include="pyfloat.cs" />
127-
<Compile Include="pyint.cs" />
128-
<Compile Include="pyiter.cs" />
129-
<Compile Include="pylist.cs" />
130-
<Compile Include="pylong.cs" />
131-
<Compile Include="pynumber.cs" />
132-
<Compile Include="pyobject.cs" />
133-
<Compile Include="pyscope.cs" />
134-
<Compile Include="pysequence.cs" />
135-
<Compile Include="pystring.cs" />
136-
<Compile Include="pythonengine.cs" />
137-
<Compile Include="pythonexception.cs" />
138-
<Compile Include="pytuple.cs" />
139-
<Compile Include="runtime.cs" />
140-
<Compile Include="typemanager.cs" />
141-
<Compile Include="typemethod.cs" />
142-
<Compile Include="Util.cs" />
143-
</ItemGroup>
144-
<ItemGroup Condition=" '$(PythonInteropFile)' != '' ">
145-
<Compile Include="$(PythonInteropFile)" />
146-
</ItemGroup>
147-
<ItemGroup Condition=" '$(PythonInteropFile)' == '' ">
148-
<Compile Include="interop27.cs" />
149-
<Compile Include="interop34.cs" />
150-
<Compile Include="interop35.cs" />
151-
<Compile Include="interop36.cs" />
152-
<Compile Include="interop37.cs" />
17+
<EmbeddedResource Include="resources\clr.py" />
15318
</ItemGroup>
19+
15420
<ItemGroup>
155-
<None Include="..\pythonnet.snk" />
21+
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
15622
</ItemGroup>
157-
<ItemGroup>
158-
<EmbeddedResource Include="resources\clr.py">
159-
<LogicalName>clr.py</LogicalName>
160-
</EmbeddedResource>
161-
</ItemGroup>
162-
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
163-
<PropertyGroup>
164-
<TargetAssembly>$(TargetPath)</TargetAssembly>
165-
<TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
166-
</PropertyGroup>
167-
<Target Name="AfterBuild">
168-
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
169-
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
170-
</Target>
171-
</Project>
23+
24+
</Project>

src/runtime/propertyobject.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ internal class PropertyObject : ExtensionType
1313
private MethodInfo getter;
1414
private MethodInfo setter;
1515

16-
[StrongNameIdentityPermission(SecurityAction.Assert)]
1716
public PropertyObject(PropertyInfo md)
1817
{
1918
getter = md.GetGetMethod(true);

src/runtime/pythonengine.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true,
205205
Runtime.PyDict_SetItemString(module_globals, "__builtins__", builtins);
206206

207207
Assembly assembly = Assembly.GetExecutingAssembly();
208-
using (Stream stream = assembly.GetManifestResourceStream("clr.py"))
209-
using (var reader = new StreamReader(stream))
208+
//using (Stream stream = assembly.GetManifestResourceStream("clr.py"))
209+
//using (var reader = new StreamReader(stream))
210210
{
211211
// add the contents of clr.py to the module
212-
string clr_py = reader.ReadToEnd();
212+
//string clr_py = reader.ReadToEnd();
213+
string clr_py = File.ReadAllText("clr.py");
213214
Exec(clr_py, module_globals, locals.Handle);
214215
}
215216

0 commit comments

Comments
 (0)