Merge from trunk
[plcapi.git] / trunk / pycurl / tests / util.py
diff --git a/trunk/pycurl/tests/util.py b/trunk/pycurl/tests/util.py
new file mode 100644 (file)
index 0000000..a1a9978
--- /dev/null
@@ -0,0 +1,38 @@
+# -*- coding: iso-8859-1 -*-
+# vi:ts=4:et
+# $Id$
+
+import os, sys
+
+#
+# prepare sys.path in case we are still in the build directory
+# see also: distutils/command/build.py (build_platlib)
+#
+
+def get_sys_path(p=None):
+    if p is None: p = sys.path
+    p = p[:]
+    try:
+        from distutils.util import get_platform
+    except ImportError:
+        return p
+    p0 = ""
+    if p: p0 = p[0]
+    #
+    plat = get_platform()
+    plat_specifier = "%s-%s" % (plat, sys.version[:3])
+    ##print plat, plat_specifier
+    #
+    for prefix in (p0, os.curdir, os.pardir,):
+        if not prefix:
+            continue
+        d = os.path.join(prefix, "build")
+        for subdir in ("lib", "lib." + plat_specifier, "lib." + plat):
+            dir = os.path.normpath(os.path.join(d, subdir))
+            if os.path.isdir(dir):
+                if dir not in p:
+                    p.insert(1, dir)
+    #
+    return p
+
+