Skip to content

Commit 51f552c

Browse files
DanielNoordcdce8p
andauthored
Remove distutils path patching (#1321)
Co-authored-by: Marc Mueller <[email protected]>
1 parent 0d12115 commit 51f552c

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Release date: TBA
2424

2525
* Require Python 3.6.2 to use astroid.
2626

27+
* Removed custom ``distutils`` handling for resolving paths to submodules.
28+
29+
Ref #1321
30+
2731
* Fix ``deque.insert()`` signature in ``collections`` brain.
2832

2933
Closes #1260

astroid/interpreter/_import/spec.py

-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import abc
1919
import collections
20-
import distutils
2120
import enum
2221
import importlib.machinery
2322
import os
@@ -161,12 +160,6 @@ def contribute_to_path(self, spec, processed):
161160
for p in sys.path
162161
if os.path.isdir(os.path.join(p, *processed))
163162
]
164-
# We already import distutils elsewhere in astroid,
165-
# so if it is the same module, we can use it directly.
166-
elif spec.name == "distutils" and spec.location in distutils.__path__:
167-
# distutils is patched inside virtualenvs to pick up submodules
168-
# from the original Python, not from the virtualenv itself.
169-
path = list(distutils.__path__)
170163
else:
171164
path = [spec.location]
172165
return path

tests/unittest_modutils.py

-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"""
2323
unit tests for module modutils (module manipulation utilities)
2424
"""
25-
import distutils.version
2625
import email
2726
import os
2827
import shutil
@@ -72,10 +71,6 @@ def test_find_egg_module(self) -> None:
7271
["data", "MyPyPa-0.1.0-py2.5.egg", self.package],
7372
)
7473

75-
def test_find_distutils_submodules_in_virtualenv(self) -> None:
76-
found_spec = spec.find_spec(["distutils", "version"])
77-
self.assertEqual(found_spec.location, distutils.version.__file__)
78-
7974

8075
class LoadModuleFromNameTest(unittest.TestCase):
8176
"""load a python module from it's name"""

0 commit comments

Comments
 (0)