Skip to content

Commit

Permalink
Remove distutils path patching (#1321)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
  • Loading branch information
DanielNoord and cdce8p authored Dec 31, 2021
1 parent 0d12115 commit 51f552c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions astroid/interpreter/_import/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import abc
import collections
import distutils
import enum
import importlib.machinery
import os
Expand Down Expand Up @@ -161,12 +160,6 @@ def contribute_to_path(self, spec, processed):
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
Expand Down
5 changes: 0 additions & 5 deletions tests/unittest_modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"""
unit tests for module modutils (module manipulation utilities)
"""
import distutils.version
import email
import os
import shutil
Expand Down Expand Up @@ -72,10 +71,6 @@ def test_find_egg_module(self) -> None:
["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"""
Expand Down

0 comments on commit 51f552c

Please sign in to comment.