diff bin/run_local.py @ 1697:5c04a54df635

fix startup (this might be breaking mypy) Ignore-this: d81817852cde18bb475ce7be80499b5d
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 26 Apr 2018 08:20:19 +0000
parents 3693b226b0b8
children 7772cc48e016
line wrap: on
line diff
--- a/bin/run_local.py	Thu Apr 26 06:43:31 2018 +0000
+++ b/bin/run_local.py	Thu Apr 26 08:20:19 2018 +0000
@@ -3,7 +3,50 @@
 # this should be turned off when the programs are installed
 
 import sys, os, socket
-sys.path.insert(0,os.path.join(os.path.dirname(sys.argv[0]),".."))
+
+def fixSysPath():
+    root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) + '/'
+
+    # this is site-packages/zope.interface-4.5.0-py2.7-nspkg.pth,
+    # slightly edited.
+    import types
+    has_mfs = sys.version_info > (3, 5);
+    p = root + 'env/local/lib/python2.7/site-packages/zope'
+    importlib = has_mfs and __import__('importlib.util');
+    has_mfs and __import__('importlib.machinery');
+    m = has_mfs and sys.modules.setdefault(
+        'zope', importlib.util.module_from_spec(
+            importlib.machinery.PathFinder.find_spec(
+                'zope', [os.path.dirname(p)])));
+    m = m or sys.modules.setdefault('zope', types.ModuleType('zope'));
+    mp = (m or []) and m.__dict__.setdefault('__path__',[]);
+    (p not in mp) and mp.append(p)
+    
+    p = root + 'env/local/lib/python2.7/site-packages/greplin'
+    importlib = has_mfs and __import__('importlib.util');
+    has_mfs and __import__('importlib.machinery');
+    m = has_mfs and sys.modules.setdefault('greplin', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('greplin', [os.path.dirname(p)])));
+    m = m or sys.modules.setdefault('greplin', types.ModuleType('greplin'));
+    mp = (m or []) and m.__dict__.setdefault('__path__',[]);
+    (p not in mp) and mp.append(p)
+
+    sys.path = [
+        root,
+        root + 'env/lib/python2.7',
+        root + 'env/lib/python2.7/plat-x86_64-linux-gnu',
+        root + 'env/lib/python2.7/lib-tk',
+        root + 'env/lib/python2.7/lib-old',
+        root + 'env/lib/python2.7/lib-dynload',
+        '/usr/lib/python2.7',
+        '/usr/lib/python2.7/plat-x86_64-linux-gnu',
+        '/usr/lib/python2.7/lib-tk',
+        root + 'env/local/lib/python2.7/site-packages',
+        root + 'env/local/lib/python2.7/site-packages/gtk-2.0',
+        root + 'env/lib/python2.7/site-packages',
+        root + 'env/lib/python2.7/site-packages/gtk-2.0',
+    ]
+
+fixSysPath()
 
 from twisted.python.failure import Failure