Skip to content

Commit a103d88

Browse files
authored
Merge pull request #3541 from pypa/bugfix/3536-msvc9-warning
Remove monkeypatching of msvc9compiler
2 parents fe8a98e + 75189d9 commit a103d88

File tree

4 files changed

+2
-292
lines changed

4 files changed

+2
-292
lines changed

changelog.d/3536.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove monkeypatching of msvc9compiler.

setuptools/monkey.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,17 @@ def patch_params(mod_name, func_name):
143143
"""
144144
Prepare the parameters for patch_func to patch indicated function.
145145
"""
146-
repl_prefix = 'msvc9_' if 'msvc9' in mod_name else 'msvc14_'
146+
repl_prefix = 'msvc14_'
147147
repl_name = repl_prefix + func_name.lstrip('_')
148148
repl = getattr(msvc, repl_name)
149149
mod = import_module(mod_name)
150150
if not hasattr(mod, func_name):
151151
raise ImportError(func_name)
152152
return repl, mod, func_name
153153

154-
# Python 2.7 to 3.4
155-
msvc9 = functools.partial(patch_params, 'distutils.msvc9compiler')
156-
157154
# Python 3.5+
158155
msvc14 = functools.partial(patch_params, 'distutils._msvccompiler')
159156

160-
try:
161-
# Patch distutils.msvc9compiler
162-
patch_func(*msvc9('find_vcvarsall'))
163-
patch_func(*msvc9('query_vcvarsall'))
164-
except ImportError:
165-
pass
166-
167157
try:
168158
# Patch distutils._msvccompiler._get_vc_env
169159
patch_func(*msvc14('_get_vc_env'))

setuptools/msvc.py

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
44
Known supported compilers:
55
--------------------------
6-
Microsoft Visual C++ 9.0:
7-
Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)
8-
Microsoft Windows SDK 6.1 (x86, x64, ia64)
9-
Microsoft Windows SDK 7.0 (x86, x64, ia64)
10-
11-
Microsoft Visual C++ 10.0:
12-
Microsoft Windows SDK 7.1 (x86, x64, ia64)
13-
146
Microsoft Visual C++ 14.X:
157
Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
168
Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
@@ -48,100 +40,6 @@ class winreg:
4840

4941
environ = dict()
5042

51-
_msvc9_suppress_errors = (
52-
# msvc9compiler isn't available on some platforms
53-
ImportError,
54-
55-
# msvc9compiler raises DistutilsPlatformError in some
56-
# environments. See #1118.
57-
distutils.errors.DistutilsPlatformError,
58-
)
59-
60-
try:
61-
from distutils.msvc9compiler import Reg
62-
except _msvc9_suppress_errors:
63-
pass
64-
65-
66-
def msvc9_find_vcvarsall(version):
67-
"""
68-
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
69-
compiler build for Python
70-
(VCForPython / Microsoft Visual C++ Compiler for Python 2.7).
71-
72-
Fall back to original behavior when the standalone compiler is not
73-
available.
74-
75-
Redirect the path of "vcvarsall.bat".
76-
77-
Parameters
78-
----------
79-
version: float
80-
Required Microsoft Visual C++ version.
81-
82-
Return
83-
------
84-
str
85-
vcvarsall.bat path
86-
"""
87-
vc_base = r'Software\%sMicrosoft\DevDiv\VCForPython\%0.1f'
88-
key = vc_base % ('', version)
89-
try:
90-
# Per-user installs register the compiler path here
91-
productdir = Reg.get_value(key, "installdir")
92-
except KeyError:
93-
try:
94-
# All-user installs on a 64-bit system register here
95-
key = vc_base % ('Wow6432Node\\', version)
96-
productdir = Reg.get_value(key, "installdir")
97-
except KeyError:
98-
productdir = None
99-
100-
if productdir:
101-
vcvarsall = join(productdir, "vcvarsall.bat")
102-
if isfile(vcvarsall):
103-
return vcvarsall
104-
105-
return get_unpatched(msvc9_find_vcvarsall)(version)
106-
107-
108-
def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
109-
"""
110-
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
111-
Microsoft Visual C++ 9.0 and 10.0 compilers.
112-
113-
Set environment without use of "vcvarsall.bat".
114-
115-
Parameters
116-
----------
117-
ver: float
118-
Required Microsoft Visual C++ version.
119-
arch: str
120-
Target architecture.
121-
122-
Return
123-
------
124-
dict
125-
environment
126-
"""
127-
# Try to get environment from vcvarsall.bat (Classical way)
128-
try:
129-
orig = get_unpatched(msvc9_query_vcvarsall)
130-
return orig(ver, arch, *args, **kwargs)
131-
except distutils.errors.DistutilsPlatformError:
132-
# Pass error if Vcvarsall.bat is missing
133-
pass
134-
except ValueError:
135-
# Pass error if environment not set after executing vcvarsall.bat
136-
pass
137-
138-
# If error, try to set environment directly
139-
try:
140-
return EnvironmentInfo(arch, ver).return_env()
141-
except distutils.errors.DistutilsPlatformError as exc:
142-
_augment_exception(exc, ver, arch)
143-
raise
144-
14543

14644
def _msvc14_find_vc2015():
14745
"""Python 3.8 "distutils/_msvccompiler.py" backport"""

setuptools/tests/test_msvc.py

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)