@@ -90,23 +90,11 @@ def _find_vc2017():
9090 return None , None
9191
9292def _find_vcvarsall (plat_spec ):
93+ # bpo-38597: Removed vcruntime return value
9394 _ , best_dir = _find_vc2017 ()
94- vcruntime = None
95- vcruntime_plat = 'x64' if 'amd64' in plat_spec else 'x86'
96- if best_dir :
97- vcredist = os .path .join (best_dir , ".." , ".." , "redist" , "MSVC" , "**" ,
98- vcruntime_plat , "Microsoft.VC14*.CRT" , "vcruntime140.dll" )
99- try :
100- import glob
101- vcruntime = glob .glob (vcredist , recursive = True )[- 1 ]
102- except (ImportError , OSError , LookupError ):
103- vcruntime = None
10495
10596 if not best_dir :
10697 best_version , best_dir = _find_vc2015 ()
107- if best_version :
108- vcruntime = os .path .join (best_dir , 'redist' , vcruntime_plat ,
109- "Microsoft.VC140.CRT" , "vcruntime140.dll" )
11098
11199 if not best_dir :
112100 log .debug ("No suitable Visual C++ version found" )
@@ -117,11 +105,7 @@ def _find_vcvarsall(plat_spec):
117105 log .debug ("%s cannot be found" , vcvarsall )
118106 return None , None
119107
120- if not vcruntime or not os .path .isfile (vcruntime ):
121- log .debug ("%s cannot be found" , vcruntime )
122- vcruntime = None
123-
124- return vcvarsall , vcruntime
108+ return vcvarsall , None
125109
126110def _get_vc_env (plat_spec ):
127111 if os .getenv ("DISTUTILS_USE_SDK" ):
@@ -130,7 +114,7 @@ def _get_vc_env(plat_spec):
130114 for key , value in os .environ .items ()
131115 }
132116
133- vcvarsall , vcruntime = _find_vcvarsall (plat_spec )
117+ vcvarsall , _ = _find_vcvarsall (plat_spec )
134118 if not vcvarsall :
135119 raise DistutilsPlatformError ("Unable to find vcvarsall.bat" )
136120
@@ -151,8 +135,6 @@ def _get_vc_env(plat_spec):
151135 if key and value
152136 }
153137
154- if vcruntime :
155- env ['py_vcruntime_redist' ] = vcruntime
156138 return env
157139
158140def _find_exe (exe , paths = None ):
@@ -180,12 +162,6 @@ def _find_exe(exe, paths=None):
180162 'win-amd64' : 'x86_amd64' ,
181163}
182164
183- # A set containing the DLLs that are guaranteed to be available for
184- # all micro versions of this Python version. Known extension
185- # dependencies that are not in this set will be copied to the output
186- # path.
187- _BUNDLED_DLLS = frozenset (['vcruntime140.dll' ])
188-
189165class MSVCCompiler (CCompiler ) :
190166 """Concrete class that implements an interface to Microsoft Visual C++,
191167 as defined by the CCompiler abstract class."""
@@ -249,7 +225,6 @@ def initialize(self, plat_name=None):
249225 self .rc = _find_exe ("rc.exe" , paths ) # resource compiler
250226 self .mc = _find_exe ("mc.exe" , paths ) # message compiler
251227 self .mt = _find_exe ("mt.exe" , paths ) # message compiler
252- self ._vcruntime_redist = vc_env .get ('py_vcruntime_redist' , '' )
253228
254229 for dir in vc_env .get ('include' , '' ).split (os .pathsep ):
255230 if dir :
@@ -260,13 +235,12 @@ def initialize(self, plat_name=None):
260235 self .add_library_dir (dir .rstrip (os .sep ))
261236
262237 self .preprocess_options = None
263- # If vcruntime_redist is available, link against it dynamically. Otherwise,
264- # use /MT[d] to build statically, then switch from libucrt[d].lib to ucrt[d].lib
265- # later to dynamically link to ucrtbase but not vcruntime .
238+ # bpo-38597: Always compile with dynamic linking
239+ # Future releases of Python 3.x will include all past
240+ # versions of vcruntime*.dll for compatibility .
266241 self .compile_options = [
267- '/nologo' , '/Ox' , '/W3' , '/GL' , '/DNDEBUG'
242+ '/nologo' , '/Ox' , '/W3' , '/GL' , '/DNDEBUG' , '/MD'
268243 ]
269- self .compile_options .append ('/MD' if self ._vcruntime_redist else '/MT' )
270244
271245 self .compile_options_debug = [
272246 '/nologo' , '/Od' , '/MDd' , '/Zi' , '/W3' , '/D_DEBUG'
@@ -275,8 +249,6 @@ def initialize(self, plat_name=None):
275249 ldflags = [
276250 '/nologo' , '/INCREMENTAL:NO' , '/LTCG'
277251 ]
278- if not self ._vcruntime_redist :
279- ldflags .extend (('/nodefaultlib:libucrt.lib' , 'ucrt.lib' ))
280252
281253 ldflags_debug = [
282254 '/nologo' , '/INCREMENTAL:NO' , '/LTCG' , '/DEBUG:FULL'
@@ -518,24 +490,11 @@ def link(self,
518490 try :
519491 log .debug ('Executing "%s" %s' , self .linker , ' ' .join (ld_args ))
520492 self .spawn ([self .linker ] + ld_args )
521- self ._copy_vcruntime (output_dir )
522493 except DistutilsExecError as msg :
523494 raise LinkError (msg )
524495 else :
525496 log .debug ("skipping %s (up-to-date)" , output_filename )
526497
527- def _copy_vcruntime (self , output_dir ):
528- vcruntime = self ._vcruntime_redist
529- if not vcruntime or not os .path .isfile (vcruntime ):
530- return
531-
532- if os .path .basename (vcruntime ).lower () in _BUNDLED_DLLS :
533- return
534-
535- log .debug ('Copying "%s"' , vcruntime )
536- vcruntime = shutil .copy (vcruntime , output_dir )
537- os .chmod (vcruntime , stat .S_IWRITE )
538-
539498 def spawn (self , cmd ):
540499 old_path = os .getenv ('path' )
541500 try :
0 commit comments