| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1f40564 commit cac82a6
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,10 @@ | |||
| 12 | 12 | <None Include="fixtures/**/*.py" CopyToOutputDirectory="PreserveNewest" /> | |
| 13 | 13 | </ItemGroup> | |
| 14 | 14 | ||
| 15 | + <PropertyGroup> | ||
| 16 | + <DefineConstants>$(DefineConstants);$(ConfiguredConstants)</DefineConstants> | ||
| 17 | + </PropertyGroup> | ||
| 18 | + | ||
| 15 | 19 | <ItemGroup> | |
| 16 | 20 | <PackageReference Include="NUnit" Version="3.*" /> | |
| 17 | 21 | <PackageReference Include="NUnit3TestAdapter" Version="3.*"> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,45 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Linq; | ||
| 4 | + using System.Reflection; | ||
| 5 | + using System.Text; | ||
| 6 | + using System.Threading.Tasks; | ||
| 7 | + | ||
| 8 | + using NUnit.Framework; | ||
| 9 | + | ||
| 10 | + using Python.Runtime; | ||
| 11 | + | ||
| 12 | + namespace Python.EmbeddingPythonTest | ||
| 13 | + { | ||
| 14 | + public class TestNativeTypeOffset | ||
| 15 | + { | ||
| 16 | + private Py.GILState _gs; | ||
| 17 | + | ||
| 18 | + [SetUp] | ||
| 19 | + public void SetUp() | ||
| 20 | + { | ||
| 21 | + _gs = Py.GIL(); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + [TearDown] | ||
| 25 | + public void Dispose() | ||
| 26 | + { | ||
| 27 | + _gs.Dispose(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /// <summary> | ||
| 31 | + /// Tests that installation has generated code for NativeTypeOffset and that it can be loaded. | ||
| 32 | + /// </summary> | ||
| 33 | + [Test] | ||
| 34 | + public void LoadNativeTypeOffsetClass() | ||
| 35 | + { | ||
| 36 | + PyObject sys = Py.Import("sys"); | ||
| 37 | + string attributeName = "abiflags"; | ||
| 38 | + if (sys.HasAttr(attributeName) && !string.IsNullOrEmpty(sys.GetAttr(attributeName).ToString())) | ||
| 39 | + { | ||
| 40 | + string typeName = "Python.Runtime.NativeTypeOffset, Python.Runtime"; | ||
| 41 | + Assert.NotNull(Type.GetType(typeName), $"{typeName} does not exist and sys.{attributeName} is not empty"); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,12 +19,6 @@ | |||
| 19 | 19 | <DefineConstants>$(DefineConstants);$(ConfiguredConstants)</DefineConstants> | |
| 20 | 20 | </PropertyGroup> | |
| 21 | 21 | ||
| 22 | - <ItemGroup Condition=" '$(PythonInteropFile)' != '' "> | ||
| 23 | - <Compile Remove="interop*.cs" /> | ||
| 24 | - <Compile Include="interop.cs" /> | ||
| 25 | - <Compile Include="$(PythonInteropFile)" /> | ||
| 26 | - </ItemGroup> | ||
| 27 | - | ||
| 28 | 22 | <ItemGroup> | |
| 29 | 23 | <None Remove="resources\clr.py" /> | |
| 30 | 24 | <EmbeddedResource Include="resources\clr.py"> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,12 @@ internal static void Initialize(Version version, BorrowedReference pyType) | |||
| 22 | 22 | thisAssembly.GetType(nativeTypeOffsetClassName, throwOnError: false) | |
| 23 | 23 | ?? thisAssembly.GetType(className, throwOnError: false); | |
| 24 | 24 | if (typeOffsetsClass is null) | |
| 25 | - throw new NotSupportedException($"Python ABI v{version} is not supported"); | ||
| 25 | + { | ||
| 26 | + var types = thisAssembly.GetTypes().Select(type => type.Name).Where(name => name.StartsWith("TypeOffset")); | ||
| 27 | + string message = $"Searching for {className}, found {string.Join(",", types)}. " + | ||
| 28 | + "If you are building Python.NET from source, make sure you have run 'python setup.py configure' to fill in configured.props"; | ||
| 29 | + throw new NotSupportedException($"Python ABI v{version} is not supported: {message}"); | ||
| 30 | + } | ||
| 26 | 31 | var typeOffsets = (ITypeOffsets)Activator.CreateInstance(typeOffsetsClass); | |
| 27 | 32 | TypeOffset.Use(typeOffsets); | |
| 28 | 33 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments