From 839bc1fec8b78188494ae9174218a20d10e4dbd2 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Tue, 19 Apr 2016 19:11:14 +0200 Subject: [PATCH] Making PR #708 more concrete Now a check is made whether PYTHONPATH is set at all. So 'normal' installations will pass that section. After that sys.path is checked whether the last element is PYTHONPATH. If it is PYTHONPATH will be moved before entry at sys.path[1], because sys.path[0] is os.curdir. Inserting PYTHONPATH in front of it might be unsave. --- cura_app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cura_app.py b/cura_app.py index 2b24b2c664..aa09f22446 100755 --- a/cura_app.py +++ b/cura_app.py @@ -6,13 +6,17 @@ import os import sys +# WORKAROUND: GITHUB-704 GITHUB-708 # It looks like setuptools creates a .pth file in # the default /usr/lib which causes the default site-packages # to be inserted into sys.path before PYTHONPATH. # This can cause issues such as having libsip loaded from # the system instead of the one provided with Cura, which causes # incompatibility issues with libArcus -sys.path.insert(1, os.environ.get('PYTHONPATH', '')) +if "PYTHONPATH" in os.environ.keys(): # If PYTHONPATH is used + if sys.path[-1] == os.environ["PYTHONPATH"]: # .. check whether PYTHONPATH is placed incorrectly at the end of sys.path. + sys.path.pop(-1) # If so remove that element.. + sys.path.insert(1, os.environ['PYTHONPATH']) # and add it at the correct place again. def exceptHook(hook_type, value, traceback):