@@ -97,28 +97,11 @@ def _find_vc2017():
97
97
}
98
98
99
99
def _find_vcvarsall (plat_spec ):
100
+ # bpo-38597: Removed vcruntime return value
100
101
_ , best_dir = _find_vc2017 ()
101
- vcruntime = None
102
-
103
- if plat_spec in PLAT_SPEC_TO_RUNTIME :
104
- vcruntime_plat = PLAT_SPEC_TO_RUNTIME [plat_spec ]
105
- else :
106
- vcruntime_plat = 'x64' if 'amd64' in plat_spec else 'x86'
107
-
108
- if best_dir :
109
- vcredist = os .path .join (best_dir , ".." , ".." , "redist" , "MSVC" , "**" ,
110
- vcruntime_plat , "Microsoft.VC14*.CRT" , "vcruntime140.dll" )
111
- try :
112
- import glob
113
- vcruntime = glob .glob (vcredist , recursive = True )[- 1 ]
114
- except (ImportError , OSError , LookupError ):
115
- vcruntime = None
116
102
117
103
if not best_dir :
118
104
best_version , best_dir = _find_vc2015 ()
119
- if best_version :
120
- vcruntime = os .path .join (best_dir , 'redist' , vcruntime_plat ,
121
- "Microsoft.VC140.CRT" , "vcruntime140.dll" )
122
105
123
106
if not best_dir :
124
107
log .debug ("No suitable Visual C++ version found" )
@@ -129,11 +112,7 @@ def _find_vcvarsall(plat_spec):
129
112
log .debug ("%s cannot be found" , vcvarsall )
130
113
return None , None
131
114
132
- if not vcruntime or not os .path .isfile (vcruntime ):
133
- log .debug ("%s cannot be found" , vcruntime )
134
- vcruntime = None
135
-
136
- return vcvarsall , vcruntime
115
+ return vcvarsall , None
137
116
138
117
def _get_vc_env (plat_spec ):
139
118
if os .getenv ("DISTUTILS_USE_SDK" ):
@@ -142,7 +121,7 @@ def _get_vc_env(plat_spec):
142
121
for key , value in os .environ .items ()
143
122
}
144
123
145
- vcvarsall , vcruntime = _find_vcvarsall (plat_spec )
124
+ vcvarsall , _ = _find_vcvarsall (plat_spec )
146
125
if not vcvarsall :
147
126
raise DistutilsPlatformError ("Unable to find vcvarsall.bat" )
148
127
@@ -163,8 +142,6 @@ def _get_vc_env(plat_spec):
163
142
if key and value
164
143
}
165
144
166
- if vcruntime :
167
- env ['py_vcruntime_redist' ] = vcruntime
168
145
return env
169
146
170
147
def _find_exe (exe , paths = None ):
@@ -194,12 +171,6 @@ def _find_exe(exe, paths=None):
194
171
'win-arm64' : 'x86_arm64'
195
172
}
196
173
197
- # A set containing the DLLs that are guaranteed to be available for
198
- # all micro versions of this Python version. Known extension
199
- # dependencies that are not in this set will be copied to the output
200
- # path.
201
- _BUNDLED_DLLS = frozenset (['vcruntime140.dll' ])
202
-
203
174
class MSVCCompiler (CCompiler ) :
204
175
"""Concrete class that implements an interface to Microsoft Visual C++,
205
176
as defined by the CCompiler abstract class."""
@@ -263,7 +234,6 @@ def initialize(self, plat_name=None):
263
234
self .rc = _find_exe ("rc.exe" , paths ) # resource compiler
264
235
self .mc = _find_exe ("mc.exe" , paths ) # message compiler
265
236
self .mt = _find_exe ("mt.exe" , paths ) # message compiler
266
- self ._vcruntime_redist = vc_env .get ('py_vcruntime_redist' , '' )
267
237
268
238
for dir in vc_env .get ('include' , '' ).split (os .pathsep ):
269
239
if dir :
@@ -274,13 +244,12 @@ def initialize(self, plat_name=None):
274
244
self .add_library_dir (dir .rstrip (os .sep ))
275
245
276
246
self .preprocess_options = None
277
- # If vcruntime_redist is available, link against it dynamically. Otherwise,
278
- # use /MT[d] to build statically, then switch from libucrt[d].lib to ucrt[d].lib
279
- # later to dynamically link to ucrtbase but not vcruntime .
247
+ # bpo-38597: Always compile with dynamic linking
248
+ # Future releases of Python 3.x will include all past
249
+ # versions of vcruntime*.dll for compatibility .
280
250
self .compile_options = [
281
- '/nologo' , '/Ox' , '/W3' , '/GL' , '/DNDEBUG'
251
+ '/nologo' , '/Ox' , '/W3' , '/GL' , '/DNDEBUG' , '/MD'
282
252
]
283
- self .compile_options .append ('/MD' if self ._vcruntime_redist else '/MT' )
284
253
285
254
self .compile_options_debug = [
286
255
'/nologo' , '/Od' , '/MDd' , '/Zi' , '/W3' , '/D_DEBUG'
@@ -289,8 +258,6 @@ def initialize(self, plat_name=None):
289
258
ldflags = [
290
259
'/nologo' , '/INCREMENTAL:NO' , '/LTCG'
291
260
]
292
- if not self ._vcruntime_redist :
293
- ldflags .extend (('/nodefaultlib:libucrt.lib' , 'ucrt.lib' ))
294
261
295
262
ldflags_debug = [
296
263
'/nologo' , '/INCREMENTAL:NO' , '/LTCG' , '/DEBUG:FULL'
@@ -532,24 +499,11 @@ def link(self,
532
499
try :
533
500
log .debug ('Executing "%s" %s' , self .linker , ' ' .join (ld_args ))
534
501
self .spawn ([self .linker ] + ld_args )
535
- self ._copy_vcruntime (output_dir )
536
502
except DistutilsExecError as msg :
537
503
raise LinkError (msg )
538
504
else :
539
505
log .debug ("skipping %s (up-to-date)" , output_filename )
540
506
541
- def _copy_vcruntime (self , output_dir ):
542
- vcruntime = self ._vcruntime_redist
543
- if not vcruntime or not os .path .isfile (vcruntime ):
544
- return
545
-
546
- if os .path .basename (vcruntime ).lower () in _BUNDLED_DLLS :
547
- return
548
-
549
- log .debug ('Copying "%s"' , vcruntime )
550
- vcruntime = shutil .copy (vcruntime , output_dir )
551
- os .chmod (vcruntime , stat .S_IWRITE )
552
-
553
507
def spawn (self , cmd ):
554
508
old_path = os .getenv ('path' )
555
509
try :
0 commit comments