set svn:keywords property for proper keywords expansion
[plcapi.git] / pycurl / tests / util.py
1 # -*- coding: iso-8859-1 -*-
2 # vi:ts=4:et
3 # $Id$
4
5 import os, sys
6
7 #
8 # prepare sys.path in case we are still in the build directory
9 # see also: distutils/command/build.py (build_platlib)
10 #
11
12 def get_sys_path(p=None):
13     if p is None: p = sys.path
14     p = p[:]
15     try:
16         from distutils.util import get_platform
17     except ImportError:
18         return p
19     p0 = ""
20     if p: p0 = p[0]
21     #
22     plat = get_platform()
23     plat_specifier = "%s-%s" % (plat, sys.version[:3])
24     ##print plat, plat_specifier
25     #
26     for prefix in (p0, os.curdir, os.pardir,):
27         if not prefix:
28             continue
29         d = os.path.join(prefix, "build")
30         for subdir in ("lib", "lib." + plat_specifier, "lib." + plat):
31             dir = os.path.normpath(os.path.join(d, subdir))
32             if os.path.isdir(dir):
33                 if dir not in p:
34                     p.insert(1, dir)
35     #
36     return p
37
38