Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 4 src/embed_tests/Python.EmbeddingTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<None Include="fixtures/**/*.py" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);$(ConfiguredConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.*" />
<PackageReference Include="NUnit3TestAdapter" Version="3.*">
Expand Down
45 changes: 45 additions & 0 deletions 45 src/embed_tests/TestNativeTypeOffset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

using NUnit.Framework;

using Python.Runtime;

namespace Python.EmbeddingPythonTest
{
public class TestNativeTypeOffset
{
private Py.GILState _gs;

[SetUp]
public void SetUp()
{
_gs = Py.GIL();
}

[TearDown]
public void Dispose()
{
_gs.Dispose();
}

/// <summary>
/// Tests that installation has generated code for NativeTypeOffset and that it can be loaded.
/// </summary>
[Test]
public void LoadNativeTypeOffsetClass()
{
PyObject sys = Py.Import("sys");
string attributeName = "abiflags";
if (sys.HasAttr(attributeName) && !string.IsNullOrEmpty(sys.GetAttr(attributeName).ToString()))
{
string typeName = "Python.Runtime.NativeTypeOffset, Python.Runtime";
Assert.NotNull(Type.GetType(typeName), $"{typeName} does not exist and sys.{attributeName} is not empty");
}
}
}
}
6 changes: 0 additions & 6 deletions 6 src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
<DefineConstants>$(DefineConstants);$(ConfiguredConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(PythonInteropFile)' != '' ">
<Compile Remove="interop*.cs" />
<Compile Include="interop.cs" />
<Compile Include="$(PythonInteropFile)" />
tminka marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

<ItemGroup>
<None Remove="resources\clr.py" />
<EmbeddedResource Include="resources\clr.py">
Expand Down
7 changes: 6 additions & 1 deletion 7 src/runtime/native/ABI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ internal static void Initialize(Version version, BorrowedReference pyType)
thisAssembly.GetType(nativeTypeOffsetClassName, throwOnError: false)
?? thisAssembly.GetType(className, throwOnError: false);
if (typeOffsetsClass is null)
throw new NotSupportedException($"Python ABI v{version} is not supported");
{
var types = thisAssembly.GetTypes().Select(type => type.Name).Where(name => name.StartsWith("TypeOffset"));
string message = $"Searching for {className}, found {string.Join(",", types)}. " +
"If you are building Python.NET from source, make sure you have run 'python setup.py configure' to fill in configured.props";
throw new NotSupportedException($"Python ABI v{version} is not supported: {message}");
}
var typeOffsets = (ITypeOffsets)Activator.CreateInstance(typeOffsetsClass);
TypeOffset.Use(typeOffsets);

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.