From 21ea0ccb2d5b8bb7e790d691d3682cdfea571255 Mon Sep 17 00:00:00 2001 From: Alexander Larsen Date: Wed, 14 Feb 2024 14:34:27 +0100 Subject: [PATCH] This fixes an issue causing Python to load plugins from the wrong directory when running isolated --- OpenTap.Python/PythonInstallAction.cs | 3 +++ OpenTap.Python/PythonSettings.cs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenTap.Python/PythonInstallAction.cs b/OpenTap.Python/PythonInstallAction.cs index d984580..b3a5f59 100644 --- a/OpenTap.Python/PythonInstallAction.cs +++ b/OpenTap.Python/PythonInstallAction.cs @@ -12,7 +12,10 @@ public class PythonInstallAction : ICustomPackageAction public bool Execute(PackageDef package, CustomPackageActionArgs customActionArgs) { if (PythonInitializer.LoadPython() == false) + { + log.Debug("Unable to load python. Skipping python install actions."); return true; + } using (Py.GIL()) { var opentap = Py.Import("opentap"); diff --git a/OpenTap.Python/PythonSettings.cs b/OpenTap.Python/PythonSettings.cs index 11489b7..feab7b2 100644 --- a/OpenTap.Python/PythonSettings.cs +++ b/OpenTap.Python/PythonSettings.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using System.Reflection; +using OpenTap.Package; namespace OpenTap.Python { @@ -43,7 +44,7 @@ public class PythonSettings : ComponentSettings public string[] GetSearchList() { var lst = new List(); - var dir = Path.GetDirectoryName(typeof(TestPlan).Assembly.Location); + var dir = Installation.Current.Directory; lst.Add(dir); var dir2 = Path.Combine(dir, "Packages", "Python"); if (Directory.Exists(dir2))