Skip to content

Commit

Permalink
Remove monkeypatching of _msvccompiler.
Browse files Browse the repository at this point in the history
The monkeypatch indicates that the functionality was ported from Python 3.8, so the version in distutils should be adequate now.
  • Loading branch information
jaraco committed Aug 27, 2024
1 parent 4c990b9 commit 4e4e23c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 1,787 deletions.
37 changes: 0 additions & 37 deletions setuptools/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

from __future__ import annotations

import functools
import inspect
import platform
import sys
import types
from importlib import import_module
from typing import TypeVar

import distutils.filelist
Expand Down Expand Up @@ -84,8 +82,6 @@ def patch_all():
'distutils.command.build_ext'
].Extension = setuptools.extension.Extension

patch_for_msvc_specialized_compiler()


def _patch_distribution_metadata():
from . import _core_metadata
Expand Down Expand Up @@ -121,36 +117,3 @@ def patch_func(replacement, target_mod, func_name):

def get_unpatched_function(candidate):
return candidate.unpatched


def patch_for_msvc_specialized_compiler():
"""
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
"""
from . import msvc

if platform.system() != 'Windows':
# Compilers only available on Microsoft Windows
return

def patch_params(mod_name, func_name):
"""
Prepare the parameters for patch_func to patch indicated function.
"""
repl_prefix = 'msvc14_'
repl_name = repl_prefix + func_name.lstrip('_')
repl = getattr(msvc, repl_name)
mod = import_module(mod_name)
if not hasattr(mod, func_name):
raise ImportError(func_name)
return repl, mod, func_name

# Python 3.5+
msvc14 = functools.partial(patch_params, 'distutils._msvccompiler')

try:
# Patch distutils._msvccompiler._get_vc_env
patch_func(*msvc14('_get_vc_env'))
except ImportError:
pass
Loading

0 comments on commit 4e4e23c

Please sign in to comment.