Skip to content

Commit b728bda

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 b728bda

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/pip/_internal/locations/_distutils.py

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
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. This is done by removing the injected
8+
# shim, if it's injected.
9+
#
10+
# See https://github.com/pypa/pip/issues/8761 for the original discussion and
11+
# rationale for why this is done within pip.
12+
try:
13+
__import__("_distutils_hack").remove_shim()
14+
except ImportError:
15+
pass
16+
617
import logging
718
import os
819
import sys

0 commit comments

Comments
 (0)