Skip to content

Commit 8f66882

Browse files
committed
Initialize gives a helpful message when the TypeOffset interop class is not configured correctly
1 parent 1f40564 commit 8f66882

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/runtime/native/ABI.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ internal static void Initialize(Version version, BorrowedReference pyType)
2222
thisAssembly.GetType(nativeTypeOffsetClassName, throwOnError: false)
2323
?? thisAssembly.GetType(className, throwOnError: false);
2424
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 develop' to fill in configured.props";
29+
throw new NotSupportedException($"Python ABI v{version} is not supported: {message}");
30+
}
2631
var typeOffsets = (ITypeOffsets)Activator.CreateInstance(typeOffsetsClass);
2732
TypeOffset.Use(typeOffsets);
2833

0 commit comments

Comments
 (0)