diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-12-31 12:40:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-31 12:40:26 +0100 |
commit | 51f552cecd15569cb651337fa7f8f9e27eeec579 (patch) | |
tree | ba64c90dda34e9d392e99fa4610be88703852a1b | |
parent | 0d1211558670cfefd95b39984b8d5f7f34837f32 (diff) | |
download | astroid-git-51f552cecd15569cb651337fa7f8f9e27eeec579.tar.gz |
Remove distutils path patching (#1321)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | astroid/interpreter/_import/spec.py | 7 | ||||
-rw-r--r-- | tests/unittest_modutils.py | 5 |
3 files changed, 4 insertions, 12 deletions
@@ -24,6 +24,10 @@ Release date: TBA * Require Python 3.6.2 to use astroid. +* Removed custom ``distutils`` handling for resolving paths to submodules. + + Ref #1321 + * Fix ``deque.insert()`` signature in ``collections`` brain. Closes #1260 diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py index 43f00153..57bab9f4 100644 --- a/astroid/interpreter/_import/spec.py +++ b/astroid/interpreter/_import/spec.py @@ -17,7 +17,6 @@ import abc import collections -import distutils import enum import importlib.machinery import os @@ -161,12 +160,6 @@ class ImportlibFinder(Finder): for p in sys.path if os.path.isdir(os.path.join(p, *processed)) ] - # We already import distutils elsewhere in astroid, - # so if it is the same module, we can use it directly. - elif spec.name == "distutils" and spec.location in distutils.__path__: - # distutils is patched inside virtualenvs to pick up submodules - # from the original Python, not from the virtualenv itself. - path = list(distutils.__path__) else: path = [spec.location] return path diff --git a/tests/unittest_modutils.py b/tests/unittest_modutils.py index a8107f70..1cd78784 100644 --- a/tests/unittest_modutils.py +++ b/tests/unittest_modutils.py @@ -22,7 +22,6 @@ """ unit tests for module modutils (module manipulation utilities) """ -import distutils.version import email import os import shutil @@ -72,10 +71,6 @@ class ModuleFileTest(unittest.TestCase): ["data", "MyPyPa-0.1.0-py2.5.egg", self.package], ) - def test_find_distutils_submodules_in_virtualenv(self) -> None: - found_spec = spec.find_spec(["distutils", "version"]) - self.assertEqual(found_spec.location, distutils.version.__file__) - class LoadModuleFromNameTest(unittest.TestCase): """load a python module from it's name""" |