Skip to content

Commit 04f2091

Browse files
committed
Remove the setuptools-provided distutils hack, if using distutils
This ensures that pip's imported copy of distutils comes from the standard library, if/when the hack needs to be used.
1 parent 9351efd commit 04f2091

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/pip/_internal/locations/_distutils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
# The following comment should be removed at some point in the future.
44
# mypy: strict-optional=False
55

6+
# If pip's going to use distutils, it should not be using the copy that setuptools
7+
# might have injected into the environment. The least-worst option for ensuring this
8+
# seems to be to try to remove the injected shim, if it's injected.
9+
try:
10+
__import__("_distutils_hack").remove_shim()
11+
except ImportError:
12+
pass
13+
614
import logging
715
import os
816
import sys

0 commit comments

Comments
 (0)