# HG changeset patch
# User Edouard Tisserant <edouard.tisserant@gmail.com>
# Date 1732056724 -3600
# Node ID 03df7946c2fab1831997133196f4ece6853445b2
# Parent  af7671a9945a2bd7df2f2db49bb3634df1c02113
IDE: Allow environment variable override in ThirdPartyPath, and use it  also for matiec.

diff -r af7671a9945a -r 03df7946c2fa ProjectController.py
--- a/ProjectController.py	Mon Nov 18 22:42:11 2024 +0100
+++ b/ProjectController.py	Tue Nov 19 23:52:04 2024 +0100
@@ -46,7 +46,7 @@
 
 import features
 import connectors
-import util.paths as paths
+import util.paths as pathutils
 from util.misc import CheckPathPerm, GetClassImporter
 from util.MiniTextControler import MiniTextControler
 from util.ProcessLogger import ProcessLogger
@@ -65,7 +65,6 @@
 from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage
 from POULibrary import UserAddressedException
 
-base_folder = paths.AbsParentDir(__file__)
 
 MATIEC_ERROR_MODEL = re.compile(
     r".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): (?:error)|(?:warning) : (.*)$")
@@ -116,7 +115,7 @@
     def findCmd(self):
         cmd = "iec2c" + (".exe" if os.name == 'nt' else "")
         paths = [
-            os.path.join(base_folder, "matiec")
+            pathutils.ThirdPartyPath("matiec")
         ]
         path = self.findObject(
             paths, lambda p: os.path.isfile(os.path.join(p, cmd)))
@@ -129,7 +128,7 @@
 
     def findLibPath(self):
         paths = [
-            os.path.join(base_folder, "matiec", "lib"),
+            pathutils.ThirdPartyPath("matiec", "lib"),
             "/usr/lib/matiec"
         ]
         path = self.findObject(
diff -r af7671a9945a -r 03df7946c2fa util/paths.py
--- a/util/paths.py	Mon Nov 18 22:42:11 2024 +0100
+++ b/util/paths.py	Tue Nov 19 23:52:04 2024 +0100
@@ -50,6 +50,10 @@
     """
     Return folder where to find sibling projects like Modbus, CanFestival, BACnet
     """
+    env_name = name.upper() + "_PATH"
+    if env_name in os.environ:
+        return os.path.join(os.environ[env_name], *suffixes)
+    
     return os.path.join(AbsParentDir(__file__, 2), name, *suffixes)
 
 def Bpath(*names):