setup.py
changeset 45933 2960b7fac966
parent 45305 e2320bb7a99f
child 45939 66f6ca2b7aee
equal deleted inserted replaced
45932:bd22900e26ac 45933:2960b7fac966
   780             self.compiler.compiler_so = self.compiler.compiler  # no -mdll
   780             self.compiler.compiler_so = self.compiler.compiler  # no -mdll
   781             self.compiler.dll_libraries = []  # no -lmsrvc90
   781             self.compiler.dll_libraries = []  # no -lmsrvc90
   782 
   782 
   783         pythonlib = None
   783         pythonlib = None
   784 
   784 
       
   785         dir = os.path.dirname(self.get_ext_fullpath('dummy'))
       
   786         self.hgtarget = os.path.join(dir, 'hg')
       
   787 
   785         if getattr(sys, 'dllhandle', None):
   788         if getattr(sys, 'dllhandle', None):
   786             # Different Python installs can have different Python library
   789             # Different Python installs can have different Python library
   787             # names. e.g. the official CPython distribution uses pythonXY.dll
   790             # names. e.g. the official CPython distribution uses pythonXY.dll
   788             # and MinGW uses libpythonX.Y.dll.
   791             # and MinGW uses libpythonX.Y.dll.
   789             _kernel32 = ctypes.windll.kernel32
   792             _kernel32 = ctypes.windll.kernel32
   805                     raise SystemExit(
   808                     raise SystemExit(
   806                         'Python DLL does not end with .dll: %s' % dllbasename
   809                         'Python DLL does not end with .dll: %s' % dllbasename
   807                     )
   810                     )
   808                 pythonlib = dllbasename[:-4]
   811                 pythonlib = dllbasename[:-4]
   809 
   812 
       
   813                 # Copy the pythonXY.dll next to the binary so that it runs
       
   814                 # without tampering with PATH.
       
   815                 fsdecode = lambda x: x
       
   816                 if sys.version_info[0] >= 3:
       
   817                     fsdecode = os.fsdecode
       
   818                 dest = os.path.join(
       
   819                     os.path.dirname(self.hgtarget),
       
   820                     fsdecode(dllbasename),
       
   821                 )
       
   822 
       
   823                 if not os.path.exists(dest):
       
   824                     shutil.copy(buf.value, dest)
       
   825 
   810         if not pythonlib:
   826         if not pythonlib:
   811             log.warn(
   827             log.warn(
   812                 'could not determine Python DLL filename; assuming pythonXY'
   828                 'could not determine Python DLL filename; assuming pythonXY'
   813             )
   829             )
   814 
   830 
   827         objects = self.compiler.compile(
   843         objects = self.compiler.compile(
   828             ['mercurial/exewrapper.c'],
   844             ['mercurial/exewrapper.c'],
   829             output_dir=self.build_temp,
   845             output_dir=self.build_temp,
   830             macros=macros,
   846             macros=macros,
   831         )
   847         )
   832         dir = os.path.dirname(self.get_ext_fullpath('dummy'))
       
   833         self.hgtarget = os.path.join(dir, 'hg')
       
   834         self.compiler.link_executable(
   848         self.compiler.link_executable(
   835             objects, self.hgtarget, libraries=[], output_dir=self.build_temp
   849             objects, self.hgtarget, libraries=[], output_dir=self.build_temp
   836         )
   850         )
   837         if self.long_paths_support:
   851         if self.long_paths_support:
   838             self.addlongpathsmanifest()
   852             self.addlongpathsmanifest()