Skip to content

Commit

Permalink
Remove monkeypatching of msvc9compiler. Fixes #3536
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 18, 2022
1 parent fe8a98e commit ef13098
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 273 deletions.
94 changes: 0 additions & 94 deletions setuptools/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,100 +48,6 @@ class winreg:

environ = dict()

_msvc9_suppress_errors = (
# msvc9compiler isn't available on some platforms
ImportError,

# msvc9compiler raises DistutilsPlatformError in some
# environments. See #1118.
distutils.errors.DistutilsPlatformError,
)

try:
from distutils.msvc9compiler import Reg
except _msvc9_suppress_errors:
pass


def msvc9_find_vcvarsall(version):
"""
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
compiler build for Python
(VCForPython / Microsoft Visual C++ Compiler for Python 2.7).
Fall back to original behavior when the standalone compiler is not
available.
Redirect the path of "vcvarsall.bat".
Parameters
----------
version: float
Required Microsoft Visual C++ version.
Return
------
str
vcvarsall.bat path
"""
vc_base = r'Software\%sMicrosoft\DevDiv\VCForPython\%0.1f'
key = vc_base % ('', version)
try:
# Per-user installs register the compiler path here
productdir = Reg.get_value(key, "installdir")
except KeyError:
try:
# All-user installs on a 64-bit system register here
key = vc_base % ('Wow6432Node\\', version)
productdir = Reg.get_value(key, "installdir")
except KeyError:
productdir = None

if productdir:
vcvarsall = join(productdir, "vcvarsall.bat")
if isfile(vcvarsall):
return vcvarsall

return get_unpatched(msvc9_find_vcvarsall)(version)


def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
"""
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
Microsoft Visual C++ 9.0 and 10.0 compilers.
Set environment without use of "vcvarsall.bat".
Parameters
----------
ver: float
Required Microsoft Visual C++ version.
arch: str
Target architecture.
Return
------
dict
environment
"""
# Try to get environment from vcvarsall.bat (Classical way)
try:
orig = get_unpatched(msvc9_query_vcvarsall)
return orig(ver, arch, *args, **kwargs)
except distutils.errors.DistutilsPlatformError:
# Pass error if Vcvarsall.bat is missing
pass
except ValueError:
# Pass error if environment not set after executing vcvarsall.bat
pass

# If error, try to set environment directly
try:
return EnvironmentInfo(arch, ver).return_env()
except distutils.errors.DistutilsPlatformError as exc:
_augment_exception(exc, ver, arch)
raise


def _msvc14_find_vc2015():
"""Python 3.8 "distutils/_msvccompiler.py" backport"""
Expand Down
179 changes: 0 additions & 179 deletions setuptools/tests/test_msvc.py

This file was deleted.

0 comments on commit ef13098

Please sign in to comment.