Browse Source

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.

Thomas-Karl Pietrowski 9 years ago
parent
commit
839bc1fec8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      cura_app.py

+ 5 - 1
cura_app.py

@@ -6,13 +6,17 @@
 import os
 import os
 import sys
 import sys
 
 
+# WORKAROUND: GITHUB-704 GITHUB-708
 # It looks like setuptools creates a .pth file in
 # It looks like setuptools creates a .pth file in
 # the default /usr/lib which causes the default site-packages
 # the default /usr/lib which causes the default site-packages
 # to be inserted into sys.path before PYTHONPATH.
 # to be inserted into sys.path before PYTHONPATH.
 # This can cause issues such as having libsip loaded from
 # This can cause issues such as having libsip loaded from
 # the system instead of the one provided with Cura, which causes
 # the system instead of the one provided with Cura, which causes
 # incompatibility issues with libArcus
 # 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):
 def exceptHook(hook_type, value, traceback):