diff options
author | Torsten Marek <shlomme@gmail.com> | 2014-11-27 22:02:49 +0100 |
---|---|---|
committer | Torsten Marek <shlomme@gmail.com> | 2014-11-27 22:02:49 +0100 |
commit | 5f1f00e16ee59e569412dcef420424636043ad21 (patch) | |
tree | 32b97e60b0542cf36ffffecec6e09b2830fe0415 /astroid/modutils.py | |
parent | 5b892016a4dcf38cd2ac650cdfdffc71578b7536 (diff) | |
download | astroid-5f1f00e16ee59e569412dcef420424636043ad21.tar.gz |
Support Python installations where sys.prefix != sys.exec_prefix.
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r-- | astroid/modutils.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py index 03cd876..68a2086 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -20,7 +20,7 @@ :type PY_SOURCE_EXTS: tuple(str) :var PY_SOURCE_EXTS: list of possible python source file extension -:type STD_LIB_DIRS: list of str +:type STD_LIB_DIRS: set of str :var STD_LIB_DIRS: directories where standard modules are located :type BUILTIN_MODULES: dict @@ -54,31 +54,33 @@ else: PY_COMPILED_EXTS = ('so',) # Notes about STD_LIB_DIRS -# Consider arch-specific installation for STD_LIB_DIR definition +# Consider arch-specific installation for STD_LIB_DIRS definition # :mod:`distutils.sysconfig` contains to much hardcoded values to rely on # # :see: `Problems with /usr/lib64 builds <http://bugs.python.org/issue1294959>`_ # :see: `FHS <http://www.pathname.com/fhs/pub/fhs-2.3.html#LIBLTQUALGTALTERNATEFORMATESSENTIAL>`_ try: - # The explicit prefix is to work around a patch in virtualenv that + # The explicit sys.prefix is to work around a patch in virtualenv that # replaces the 'real' sys.prefix (i.e. the location of the binary) # with the prefix from which the virtualenv was created. This throws # off the detection logic for standard library modules, thus the # workaround. - STD_LIB_DIRS = [ + STD_LIB_DIRS = { get_python_lib(standard_lib=True, prefix=sys.prefix), - get_python_lib(standard_lib=True)] + # Take care of installations where exec_prefix != prefix. + get_python_lib(standard_lib=True, prefix=sys.exec_prefix), + get_python_lib(standard_lib=True)} if os.name == 'nt': - STD_LIB_DIRS.append(os.path.join(sys.prefix, 'dlls')) + STD_LIB_DIRS.add(os.path.join(sys.prefix, 'dlls')) try: # real_prefix is defined when running inside virtualenv. - STD_LIB_DIRS.append(os.path.join(sys.real_prefix, 'dlls')) + STD_LIB_DIRS.add(os.path.join(sys.real_prefix, 'dlls')) except AttributeError: pass # get_python_lib(standard_lib=1) is not available on pypy, set STD_LIB_DIR to # non-valid path, see https://bugs.pypy.org/issue1164 except DistutilsPlatformError: - STD_LIB_DIRS = [] + STD_LIB_DIRS = set() EXT_LIB_DIR = get_python_lib() |