@@ -539,6 +539,25 @@ def _check_vc(self):
539539 print ("-- ATLMFC paths likely missing (Required for win32ui)" )
540540 return vcbase , vcverdir
541541
542+ def _verstamp (self , filename ):
543+ """
544+ Stamp the version of the built target.
545+ Do this externally to avoid suddenly dragging in the
546+ modules needed by this process.
547+ """
548+ self .spawn (
549+ [
550+ sys .executable ,
551+ Path (__file__ ).parent / "win32" / "Lib" / "win32verstamp.py" ,
552+ f"--version={ pywin32_version } " ,
553+ "--comments=https://github.com/mhammond/pywin32" ,
554+ f"--original-filename={ os .path .basename (filename )} " ,
555+ "--product=PyWin32" ,
556+ "--quiet" if "-v" not in sys .argv else "" ,
557+ filename ,
558+ ]
559+ )
560+
542561 def build_extensions (self ):
543562 # First, sanity-check the 'extensions' list
544563 self .check_extensions_list (self .extensions )
@@ -598,24 +617,6 @@ def build_extensions(self):
598617 print ("-- compiler.library_dirs:" , self .compiler .library_dirs )
599618 raise RuntimeError ("Too many extensions skipped, check build environment" )
600619
601- for ext in [* self .extensions , * W32_exe_files ]:
602- # Stamp the version of the built target.
603- # Do this externally to avoid suddenly dragging in the
604- # modules needed by this process, and which we will soon try and update.
605- ext_path = self .get_ext_fullpath (ext .name )
606- self .spawn (
607- [
608- sys .executable ,
609- Path (__file__ ).parent / "win32" / "Lib" / "win32verstamp.py" ,
610- f"--version={ pywin32_version } " ,
611- "--comments=https://github.com/mhammond/pywin32" ,
612- f"--original-filename={ os .path .basename (ext_path )} " ,
613- "--product=PyWin32" ,
614- "--quiet" if "-v" not in sys .argv else "" ,
615- ext_path ,
616- ]
617- )
618-
619620 # Not sure how to make this completely generic, and there is no
620621 # need at this stage.
621622 self ._build_scintilla ()
@@ -701,6 +702,8 @@ def build_exefile(self, ext):
701702 build_temp = self .build_temp ,
702703 )
703704
705+ self ._verstamp (full_name )
706+
704707 def build_extension (self , ext ):
705708 # Some of these extensions are difficult to build, requiring various
706709 # hard-to-track libraries et (eg, exchange sdk, etc). So we
@@ -741,6 +744,7 @@ def build_extension(self, ext):
741744
742745 try :
743746 build_ext .build_extension (self , ext )
747+ self ._verstamp (self .get_ext_fullpath (ext .name ))
744748 # Convincing distutils to create .lib files with the name we
745749 # need is difficult, so we just hack around it by copying from
746750 # the created name to the name we need.
@@ -890,8 +894,9 @@ def swig_sources(self, sources, ext=None):
890894
891895
892896class my_compiler (MSVCCompiler ):
893- # Work around bpo-36302/bpo-42009 - it sorts sources but this breaks
894- # support for building .mc files etc :(
897+ # Work around python/cpython#80483 / python/cpython#86175
898+ # it sorts sources but this breaks support for building .mc files etc :(
899+ # See pypa/setuptools#4986 / pypa/distutils#370 for potential upstream fix.
895900 def compile (self , sources , ** kwargs ):
896901 # re-sort the list of source files but ensure all .mc files come first.
897902 def key_reverse_mc (a ):
0 commit comments