Mercurial > hg
comparison setup.py @ 45933:2960b7fac966
setup: copy pythonXY.dll next to the hg.exe wrapper when building
This avoids the problem of having the newly built binary complaining that it
can't find the DLL. There is an option in the python.org installer to add the
python install to PATH (which defaulted to "on" with py2, and therefore was not
an issue up to this point), but that makes switching between python versions
harder.
This shouldn't be an issue with the PyOxidizer binary, but that current has
issues running some of the tests, and took noticeably longer to build last time
I tried it.
Differential Revision: https://phab.mercurial-scm.org/D9362
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 21 Nov 2020 16:20:49 -0500 |
parents | e2320bb7a99f |
children | 66f6ca2b7aee |
comparison
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() |