Skip to content

Commit

Permalink
Suppress distutils replacement when building or testing CPython. Fixes
Browse files Browse the repository at this point in the history
…#2965. Fixes #3007.
  • Loading branch information
jaraco committed Jan 16, 2022
1 parent 448b840 commit 336facd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions _distutils_hack/__init__.py
Expand Up @@ -89,6 +89,9 @@ def find_spec(self, fullname, path, target=None):
return method()

def spec_for_distutils(self):
if self.is_cpython():
return

import importlib
import importlib.abc
import importlib.util
Expand Down Expand Up @@ -118,6 +121,14 @@ def exec_module(self, module):
'distutils', DistutilsLoader(), origin=mod.__file__
)

@staticmethod
def is_cpython():
"""
Suppress supplying distutils for CPython (build and tests).
Ref #2965 and #3007.
"""
return os.path.isfile('pybuilddir.txt')

def spec_for_pip(self):
"""
Ensure stdlib distutils when running under pip.
Expand Down
1 change: 1 addition & 0 deletions changelog.d/3031.misc.rst
@@ -0,0 +1 @@
Suppress distutils replacement when building or testing CPython.
Empty file added changelog.d/NNN.misc.rst
Empty file.

0 comments on commit 336facd

Please sign in to comment.