Skip to content

Commit b4fb917

Browse files
authored
Merge pull request #4600 from pypa/debt/msvc-monkey
Remove monkeypatching of _msvccompiler.
2 parents 5f8215d + 18a44d8 commit b4fb917

File tree

4 files changed

+1
-1872
lines changed

4 files changed

+1
-1872
lines changed

newsfragments/4600.removal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed the monkeypatching of distutils._msvccompiler. Now all compiler logic is consolidated in distutils.

setuptools/monkey.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
from __future__ import annotations
66

7-
import functools
87
import inspect
98
import platform
109
import sys
1110
import types
12-
from importlib import import_module
1311
from typing import Type, TypeVar, cast, overload
1412

1513
import distutils.filelist
@@ -91,8 +89,6 @@ def patch_all():
9189
'distutils.command.build_ext'
9290
].Extension = setuptools.extension.Extension
9391

94-
patch_for_msvc_specialized_compiler()
95-
9692

9793
def _patch_distribution_metadata():
9894
from . import _core_metadata
@@ -128,36 +124,3 @@ def patch_func(replacement, target_mod, func_name):
128124

129125
def get_unpatched_function(candidate):
130126
return candidate.unpatched
131-
132-
133-
def patch_for_msvc_specialized_compiler():
134-
"""
135-
Patch functions in distutils to use standalone Microsoft Visual C++
136-
compilers.
137-
"""
138-
from . import msvc
139-
140-
if platform.system() != 'Windows':
141-
# Compilers only available on Microsoft Windows
142-
return
143-
144-
def patch_params(mod_name, func_name):
145-
"""
146-
Prepare the parameters for patch_func to patch indicated function.
147-
"""
148-
repl_prefix = 'msvc14_'
149-
repl_name = repl_prefix + func_name.lstrip('_')
150-
repl = getattr(msvc, repl_name)
151-
mod = import_module(mod_name)
152-
if not hasattr(mod, func_name):
153-
raise ImportError(func_name)
154-
return repl, mod, func_name
155-
156-
# Python 3.5+
157-
msvc14 = functools.partial(patch_params, 'distutils._msvccompiler')
158-
159-
try:
160-
# Patch distutils._msvccompiler._get_vc_env
161-
patch_func(*msvc14('_get_vc_env'))
162-
except ImportError:
163-
pass

0 commit comments

Comments
 (0)