Skip to content

Commit 908f0f0

Browse files
committed
Move interface to separate DLL for simpler dynamic loading
1 parent 0185bcb commit 908f0f0

File tree

9 files changed

+22
-17
lines changed

9 files changed

+22
-17
lines changed

Python.Runtime.Native/ILibPython.cs renamed to Python.Runtime.Interfaces/ILibPython.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Threading;
66
using System.Collections.Generic;
77

8-
namespace Python.Runtime.Native
8+
namespace Python.Runtime.Interfaces
99
{
1010
public interface ILibPython
1111
{
@@ -347,6 +347,7 @@ public interface ILibPython
347347
int Py_AddPendingCall(IntPtr func, IntPtr arg);
348348
int Py_MakePendingCalls();
349349

350-
int Py_NoSiteFlag { get; set; }
350+
int GetPyNoSiteFlag();
351+
void SetPyNoSiteFlag(int val);
351352
}
352353
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>

Python.Runtime.Native/AssemblyInfo.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

Python.Runtime.Native/Python.Runtime.Native.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<PackageReference Include="AdvancedDLSupport" Version="3.1.0" />
1010
</ItemGroup>
1111

12+
<ItemGroup>
13+
<ProjectReference Include="..\Python.Runtime.Interfaces\Python.Runtime.Interfaces.csproj" />
14+
</ItemGroup>
15+
1216
</Project>

Python.Runtime.Native/CustomMarshaler.cs renamed to Python.Runtime/CustomMarshaler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public static ICustomMarshaler GetInstance(string cookie)
218218
internal class Utf8Marshaler : MarshalerBase
219219
{
220220
private static readonly MarshalerBase Instance = new Utf8Marshaler();
221-
private static readonly Encoding PyEncoding = Encoding.UTF8;
221+
private static new readonly Encoding PyEncoding = Encoding.UTF8;
222222

223223
public override IntPtr MarshalManagedToNative(object managedObj)
224224
{

Python.Runtime/Python.Runtime.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<ProjectReference Include="..\Python.Runtime.Native\Python.Runtime.Native.csproj" />
15+
<ProjectReference Include="..\Python.Runtime.Interfaces\Python.Runtime.Interfaces.csproj" />
1516
</ItemGroup>
1617

1718
</Project>

Python.Runtime/runtime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,9 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size)
979979

980980
internal static void SetNoSiteFlag()
981981
{
982-
Py_NoSiteFlag = 1;
982+
SetPyNoSiteFlag(1);
983983
}
984984

985-
static Native.ILibPython LibPython;
985+
static Interfaces.ILibPython LibPython;
986986
}
987987
}

Python.Runtime/runtime_.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ partial class Runtime {
213213
internal static System.IntPtr PyMethod_Function(System.IntPtr ob) => LibPython.PyMethod_Function(ob);
214214
internal static System.Int32 Py_AddPendingCall(System.IntPtr func, System.IntPtr arg) => LibPython.Py_AddPendingCall(func, arg);
215215
internal static System.Int32 Py_MakePendingCalls() => LibPython.Py_MakePendingCalls();
216-
internal static System.Int32 Py_NoSiteFlag {
217-
get => LibPython.Py_NoSiteFlag;
218-
set { LibPython.Py_NoSiteFlag = value; }
219-
}
216+
internal static System.Int32 GetPyNoSiteFlag() => LibPython.GetPyNoSiteFlag();
217+
internal static void SetPyNoSiteFlag(System.Int32 val) => LibPython.SetPyNoSiteFlag(val);
220218
}
221219
}

Python.Runtime/runtime_.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ namespace Python.Runtime {
2020
return type.ToString();
2121
}
2222

23-
var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Native/bin/Debug/netstandard2.0/Python.Runtime.Native.dll";
23+
var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Interfaces/bin/Debug/netstandard2.0/Python.Runtime.Interfaces.dll";
2424
var assembly = Assembly.LoadFile(path);
25-
var type = assembly.GetType("Python.Runtime.Native.ILibPython");
25+
var type = assembly.GetType("Python.Runtime.Interfaces.ILibPython");
2626
const BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance;
2727
var methods = type.GetMethods(flags);
2828

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy