summaryrefslogtreecommitdiff
path: root/astroid/modutils.py
diff options
context:
space:
mode:
authorhippo91 <guillaume.peillex@gmail.com>2020-12-28 15:47:08 +0100
committerhippo91 <guillaume.peillex@gmail.com>2020-12-28 15:47:08 +0100
commit2faedeccfee0fa6232433ea9125c8b01c03125e0 (patch)
treea7453b5fdf85565220c77c4d5db88f0f9af722f9 /astroid/modutils.py
parentd75cb3c751758a0b205efaa07545f714567d4c83 (diff)
downloadastroid-git-2faedeccfee0fa6232433ea9125c8b01c03125e0.tar.gz
Adds comment to explain the use of sys.base_prefix
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r--astroid/modutils.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py
index 87d58b4f..2cab500e 100644
--- a/astroid/modutils.py
+++ b/astroid/modutils.py
@@ -90,6 +90,17 @@ if os.name == "nt":
pass
if platform.python_implementation() == "PyPy":
+ # The get_python_lib(standard_lib=True) function does not give valid
+ # result with pypy in a virtualenv.
+ # In a virtual environment, with CPython implementation the call to this function returns a path toward
+ # the binary (its libraries) which has been used to create the virtual environment.
+ # Not with pypy implementation.
+ # The only way to retrieve such information is to use the sys.base_prefix hint.
+ # It's worth noticing that under CPython implementation the return values of
+ # get_python_lib(standard_lib=True) and get_python_lib(santdard_lib=True, prefix=sys.base_prefix)
+ # are the same.
+ # In the lines above, We could have replace the call to get_python_lib(standard=True)
+ # with the one using prefix=sys.base_prefix but we prefer modifying only what deals with pypy.
STD_LIB_DIRS.add(get_python_lib(standard_lib=True, prefix=sys.base_prefix))
_root = os.path.join(sys.prefix, "lib_pypy")
STD_LIB_DIRS.add(_root)
@@ -535,9 +546,6 @@ def is_standard_module(modname, std_path=None):
return False
if std_path is None:
std_path = STD_LIB_DIRS
- if modname == "hashlib":
- print(f"Module {modname} is located in {filename}")
- print(f"STD_LIB_DIRS are {STD_LIB_DIRS}")
for path in std_path:
if filename.startswith(_cache_normalize_path(path)):
return True