Cross-platform builds for Python plugins?

In our project we use both C# and Python languages. I’ve set a pipeline in GitLab that successfully builds packages implemented in both languages. The pipeline uses the recommended OpenTAP docker image based on Linux, namely this one.

Now, when I install the packages generated by the pipeline on Windows I’m seeing that all instruments, DUTs, and steps that come from plugins implemented in Python are broken. This doesn’t happen with the plugins that are implemented in C#.

Just a few examples of the issues:

11:52:16.445  Serializer   Exception: Could not load file or assembly 'System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.`
12:01:21.347  Main         Caught exception while instantiating test step of type 'Python.XXXXXXXXXXXXX'.
12:01:21.347  Main         Exception: Exception has been thrown by the target of an invocation.
12:01:21.347  Main             at Keysight.OpenTap.Gui.TestPlanGrid.a(ITypeData A_0, Action& A_1)
12:01:21.347  Main           Inner exception: Could not load file or assembly 'System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
12:01:21.348  Main             at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
12:01:21.348  Main             at System.Reflection.RuntimePropertyInfo.get_Signature()
12:01:21.348  Main             at System.Reflection.RuntimePropertyInfo.get_PropertyType()
12:01:21.348  Main             at Keysight.OpenTap.Plugins.Python.PythonStepWrapper.loadDefaultResources(Type t)
12:01:21.348  Main             at Keysight.OpenTap.Plugins.Python.PythonStepWrapper.load(String name, String moduleName)
12:01:21.348  Main             at PythonXXXXXXX.GetInput.load_instance()
12:01:21.348  Main             at Keysight.OpenTap.Plugins.Python.PythonStepWrapper..ctor()
12:01:21.348  Main             at Python.XXXXXX.DigitalIO..ctor()
12:01:21.348  Main             at Python.XXXXXX.GetInput..ctor()
12:01:21.349  Main         Exception caught at:
12:01:21.349  Main             at OpenTap.ITestStep AddStepToPlan(OpenTap.ITypeData, OpenTap.ITestStepParent, Boolean)
12:01:21.349  Main             at Void c(OpenTap.ITypeData, Boolean)
12:01:21.349  Main             at Void c(OpenTap.ITypeData)
12:01:21.349  Main             at Void i(System.Object, System.Windows.RoutedEventArgs)
12:01:21.349  Main             ...

Is it supposed to work or do I have to use Windows in the pipeline?

Thanks,
Tatiana

If you do cross-platform builds you need to target .netstandard2.0.

In this case it seems that you are shipping System.Private.CoreLib for .net 6.0. Any chance you can share the wrapper DLL and/or the package.xml generated in the TapPackage?

@rolf_madsen Thanks for your input, that makes sense.

I think I know how to target .netstandard2.0 for the C# part but not sure how to do it for the Python plugins. Could you give me some hints?

I’m also attaching PluginExample DLL built in the Docker, it fully reproduces the issue (had to change the extension to PDF to be able to upload it).

Python.PluginExample.pdf (17 KB)

OK, I think the C# compiler used on python adds some references that are not compatible with .net 4.8. Unfortunately, I don’t think it is possible for you to specify this.

The easiest is probably to build on windows or adding the following to the package.xml (Although I am not sure it will work):

<File ...>
   <IgnoreDependency>System.ComponentModel.Primitives</IgnoreDependency>
   <IgnoreDependency>System.Private.CoreLib</IgnoreDependency>
   <IgnoreDependency>System.Private.Xml</IgnoreDependency>
</File>

@rolf_madsen Tried IgnoreDependency approach, unfortunately it doesn’t seem to help. Is there anything else I can try before switching to Windows?

I am not sure. Could it be due to some of the dependencies you import into your project via the python code? I think we might have to do some code changes to make it select a different target framework.

As it’s reproducible with Python PluginExample, I assume it’s not related to dependencies.

@rolf_madsen I’ve been familiarizing myself with Python plugin code and trying out things mostly in WrapperBuilder, unfortunately without luck so far.

I would appreciate any hints from your side as having Windows in the pipeline is something I’d like to avoid by all means.