LocalRuntime: Allow overriding local runtime python binary path using BEREMIZPYTHONPATH environment variable. wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 28 Jul 2022 13:24:49 +0200
branchwxPython4
changeset 3566 7f5659b1eeb8
parent 3565 6d3cb1ab1ef7
child 3567 d6d9ecd07a93
LocalRuntime: Allow overriding local runtime python binary path using BEREMIZPYTHONPATH environment variable.
LocalRuntimeMixin.py
--- a/LocalRuntimeMixin.py	Wed Jul 27 21:34:23 2022 +0200
+++ b/LocalRuntimeMixin.py	Thu Jul 28 13:24:49 2022 +0200
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+
+import os
 import sys
 import tempfile
 import random
@@ -7,6 +9,11 @@
 from util.ProcessLogger import ProcessLogger
 from util.paths import Bpath
 
+LocalRuntimeInterpreterPath = \
+    os.environ["BEREMIZPYTHONPATH"] \
+    if os.environ.has_key("BEREMIZPYTHONPATH") \
+    else sys.executable
+
 class LocalRuntimeMixin():
 
     def __init__(self, log, use_gui=True):
@@ -27,7 +34,7 @@
             self.local_runtime = ProcessLogger(
                 self.local_runtime_log,
                 "\"%s\" \"%s\" -p %s -i localhost %s %s" % (
-                    sys.executable,
+                    LocalRuntimeInterpreterPath,
                     Bpath("Beremiz_service.py"),
                     self.runtime_port,
                     {False: "-x 0", True: "-x 1"}[self.use_gui],