Skip to content

Commit fcb0c84

Browse files
authored
Merge pull request #11298 from pradyunsg/remove-distutils-shim
2 parents 0231a1d + a14f141 commit fcb0c84

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

news/11298.bugfix.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Ensure that things work correctly in environments where setuptools-injected
2+
``distutils`` is available by default. This is done by cooperating with
3+
setuptools' injection logic to ensure that pip uses the ``distutils`` from the
4+
Python standard library instead.

src/pip/_internal/locations/_distutils.py

Lines changed: 11 additions & 0 deletions
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)