Skip to content

Remove distutils path patching #1321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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