From e9e5c7fc61748b8b7cc73c948556fc9a830c162c Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Sat, 3 Dec 2016 11:47:46 +0200 Subject: Use sys.base_exec_prefix in case sys.real_prefix is not defined sys.real_prefix is an addition of the *virtualenv* library, but it is not added when a virtual environment is created with the builtin *venv* library. In the latter's case, sys.base_exec_prefix is the one pointing to the original installation of Python. Now, in case sys.real_prefix is not defined, we fallback to sys.base_exec_prefix. --- astroid/modutils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'astroid') diff --git a/astroid/modutils.py b/astroid/modutils.py index b39d03d9..2854e5f1 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -66,10 +66,18 @@ except DistutilsPlatformError: if os.name == 'nt': STD_LIB_DIRS.add(os.path.join(sys.prefix, 'dlls')) try: - # real_prefix is defined when running inside virtualenv. + # real_prefix is defined when running inside virtual environments, + # created with the **virtualenv** library. STD_LIB_DIRS.add(os.path.join(sys.real_prefix, 'dlls')) except AttributeError: - pass + # sys.base_exec_prefix is always defined, but in a virtual environment + # created with the stdlib **venv** module, it points to the original + # installation, if the virtual env is activated. + try: + STD_LIB_DIRS.add(os.path.join(sys.base_exec_prefix, 'dlls')) + except AttributeError: + pass + if platform.python_implementation() == 'PyPy': _root = os.path.join(sys.prefix, 'lib_pypy') STD_LIB_DIRS.add(_root) -- cgit v1.2.1