# Cross-platform builds for Python plugins?

**URL:** https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737
**Category:** Technical
**Tags:** plugin
**Created:** [June 21, 2022, 10:11am UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737 "2022-06-21T10:11:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)
#### Post date: [June 21, 2022, 10:11am UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/1 "2022-06-21T10:11:17Z")

</div>

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](https://hub.docker.com/layers/opentap/opentapio/opentap/9.17.1-bionic/images/sha256-70ad7ea0e901188d350eef0b80eff9d6badf5d2725638a68027212a9bb3a20ec?context=explore).

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:

```csharp
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.`

```

```csharp
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

---

<div class="post-metadata">

### Author: ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)
#### Post date: [June 21, 2022, 12:51pm UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/2 "2022-06-21T12:51:58Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)
#### Post date: [June 21, 2022, 2:16pm UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/3 "2022-06-21T14:16:43Z")

</div>

@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](https://forum.opentap.io/uploads/short-url/49UgZnn3656i5wZQ6Mcn2TQtFQC.pdf) (17 KB)

---

<div class="post-metadata">

### Author: ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)
#### Post date: [June 21, 2022, 2:41pm UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/4 "2022-06-21T14:41:15Z")

</div>

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):

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

```

---

<div class="post-metadata">

### Author: ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)
#### Post date: [June 21, 2022, 3:11pm UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/5 "2022-06-21T15:11:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)
#### Post date: [June 23, 2022, 7:55am UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/6 "2022-06-23T07:55:59Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)
#### Post date: [June 23, 2022, 7:59am UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/7 "2022-06-23T07:59:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)
#### Post date: [June 27, 2022, 2:35pm UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/8 "2022-06-27T14:35:41Z")

</div>

@rolf_madsen I’ve been familiarizing myself with Python plugin code and trying out things mostly in [WrapperBuilder](https://gitlab.com/OpenTAP/Plugins/python/-/blob/master/Keysight.OpenTap.Plugins.Python/SDK/WrapperBuilder.cs), 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.

---

<div class="post-metadata">

### Author: ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)
#### Post date: [June 29, 2022, 8:46pm UTC](https://forum.opentap.io/t/cross-platform-builds-for-python-plugins/737/9 "2022-06-29T20:46:11Z")

</div>

@tatiana.boye, sorry to say, I don’t know how you can accomplish this.

I know it will be fixed in 3.0 in the plugin, but I am actually not sure how you can build it in a way that avoids the .net6 dependencies and I am out of ideas.
