changeset 4302:775e8f24c1b1

Fixup sys.path to accomodate for complete libraries under MoinMoin.support
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 13 Aug 2008 21:06:45 +0200
parents c689dfa55de1
children eb463542664e
files MoinMoin/web/__init__.py
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/__init__.py	Wed Aug 13 21:05:42 2008 +0200
+++ b/MoinMoin/web/__init__.py	Wed Aug 13 21:06:45 2008 +0200
@@ -8,3 +8,26 @@
     @copyright: 2008-2008 MoinMoin:FlorianKrupicka
     @license: GNU GPL, see COPYING for details.
 """
+
+def _fixup_deps():
+    """
+    Alter the system path to import some 3rd party dependencies from
+    inside the MoinMoin.support package. This is meant for deps
+    used inside this package, which are mainly werkzeug and flup.
+    """
+    import sys, os
+    from MoinMoin import support
+    dirname = os.path.dirname(support.__file__)
+    dirname = os.path.abspath(dirname)
+    found = False
+    for path in sys.path:
+        if os.path.abspath(path) == dirname:
+            found = True
+            break
+    if not found:
+        sys.path.append(dirname)
+
+try:
+    _fixup_deps()
+finally:
+    del _fixup_deps