comparison setup.py @ 33669:7686cbb0ba41 stable

setup: fix installing in a mingw environment The addition, in 9a4adc76c88a, of a hack for the MSVC compiler class was overwriting the original class for the Mingw32CCompiler class, leading to an error when the HackedMingw32CCompiler is instantiated. Differential Revision: https://phab.mercurial-scm.org/D329
author Mike Hommey <mh@glandium.org>
date Fri, 11 Aug 2017 10:16:00 +0900
parents 47829b89c8c6
children af20468eb0a4
comparison
equal deleted inserted replaced
33668:8de8f8a91f2d 33669:7686cbb0ba41
782 782
783 try: 783 try:
784 from distutils import cygwinccompiler 784 from distutils import cygwinccompiler
785 785
786 # the -mno-cygwin option has been deprecated for years 786 # the -mno-cygwin option has been deprecated for years
787 compiler = cygwinccompiler.Mingw32CCompiler 787 mingw32compilerclass = cygwinccompiler.Mingw32CCompiler
788 788
789 class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler): 789 class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler):
790 def __init__(self, *args, **kwargs): 790 def __init__(self, *args, **kwargs):
791 compiler.__init__(self, *args, **kwargs) 791 mingw32compilerclass.__init__(self, *args, **kwargs)
792 for i in 'compiler compiler_so linker_exe linker_so'.split(): 792 for i in 'compiler compiler_so linker_exe linker_so'.split():
793 try: 793 try:
794 getattr(self, i).remove('-mno-cygwin') 794 getattr(self, i).remove('-mno-cygwin')
795 except ValueError: 795 except ValueError:
796 pass 796 pass
807 # Allow compiler/linker flags to be added to Visual Studio builds. Passing 807 # Allow compiler/linker flags to be added to Visual Studio builds. Passing
808 # extra_link_args to distutils.extensions.Extension() doesn't have any 808 # extra_link_args to distutils.extensions.Extension() doesn't have any
809 # effect. 809 # effect.
810 from distutils import msvccompiler 810 from distutils import msvccompiler
811 811
812 compiler = msvccompiler.MSVCCompiler 812 msvccompilerclass = msvccompiler.MSVCCompiler
813 813
814 class HackedMSVCCompiler(msvccompiler.MSVCCompiler): 814 class HackedMSVCCompiler(msvccompiler.MSVCCompiler):
815 def initialize(self): 815 def initialize(self):
816 compiler.initialize(self) 816 msvccompilerclass.initialize(self)
817 # "warning LNK4197: export 'func' specified multiple times" 817 # "warning LNK4197: export 'func' specified multiple times"
818 self.ldflags_shared.append('/ignore:4197') 818 self.ldflags_shared.append('/ignore:4197')
819 self.ldflags_shared_debug.append('/ignore:4197') 819 self.ldflags_shared_debug.append('/ignore:4197')
820 820
821 msvccompiler.MSVCCompiler = HackedMSVCCompiler 821 msvccompiler.MSVCCompiler = HackedMSVCCompiler