comparison setup.py @ 49395:747c4fc20886

setup: unconditionally enable the `long-paths-support` option on Windows I don't see anything talking about why this was experimental in the first place, but maybe it was concern about the level of python2 support for it. But now, both `python.exe` and the PyOxidizer build of `hg.exe` have a manifest that enables it, so leaving it off would mean some Mercurial installations could operate on a repo with long paths, and others couldn't. Note that only the wide character functions (XxxW) will have the length restriction lifted. Sadly, distutils applies `/MANIFEST:EMBED` to the linker in a way that can't easily be turned off, so we can't use `/MANIFESTFILE` with `extra_preargs` on `link_executable`. Fortunately, the compiler object provides a path to the `mt.exe` it found during initialization, because the previous incarnation seems to have assumed it is being run within an activated Visual Studio environment. That causes MSYS builds to fail, and probably would have broke the CI environment.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 18 Jul 2022 17:19:56 -0400
parents 5cf73de964e1
children ece490b02a9b
comparison
equal deleted inserted replaced
49394:5cf73de964e1 49395:747c4fc20886
664 f.write(out) 664 f.write(out)
665 665
666 666
667 class buildhgexe(build_ext): 667 class buildhgexe(build_ext):
668 description = 'compile hg.exe from mercurial/exewrapper.c' 668 description = 'compile hg.exe from mercurial/exewrapper.c'
669 user_options = build_ext.user_options + [
670 (
671 'long-paths-support',
672 None,
673 'enable support for long paths on '
674 'Windows (off by default and '
675 'experimental)',
676 ),
677 ]
678 669
679 LONG_PATHS_MANIFEST = """ 670 LONG_PATHS_MANIFEST = """
680 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 671 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
681 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 672 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
682 <application> 673 <application>
687 </application> 678 </application>
688 </assembly>""" 679 </assembly>"""
689 680
690 def initialize_options(self): 681 def initialize_options(self):
691 build_ext.initialize_options(self) 682 build_ext.initialize_options(self)
692 self.long_paths_support = False
693 683
694 def build_extensions(self): 684 def build_extensions(self):
695 if os.name != 'nt': 685 if os.name != 'nt':
696 return 686 return
697 if isinstance(self.compiler, HackedMingw32CCompiler): 687 if isinstance(self.compiler, HackedMingw32CCompiler):
772 macros=[('_UNICODE', None), ('UNICODE', None)], 762 macros=[('_UNICODE', None), ('UNICODE', None)],
773 ) 763 )
774 self.compiler.link_executable( 764 self.compiler.link_executable(
775 objects, self.hgtarget, libraries=[], output_dir=self.build_temp 765 objects, self.hgtarget, libraries=[], output_dir=self.build_temp
776 ) 766 )
777 if self.long_paths_support: 767
778 self.addlongpathsmanifest() 768 self.addlongpathsmanifest()
779 769
780 def addlongpathsmanifest(self): 770 def addlongpathsmanifest(self):
781 r"""Add manifest pieces so that hg.exe understands long paths 771 """Add manifest pieces so that hg.exe understands long paths
782
783 This is an EXPERIMENTAL feature, use with care.
784 To enable long paths support, one needs to do two things:
785 - build Mercurial with --long-paths-support option
786 - change HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\
787 LongPathsEnabled to have value 1.
788
789 Please ignore 'warning 81010002: Unrecognized Element "longPathAware"';
790 it happens because Mercurial uses mt.exe circa 2008, which is not
791 yet aware of long paths support in the manifest (I think so at least).
792 This does not stop mt.exe from embedding/merging the XML properly.
793 772
794 Why resource #1 should be used for .exe manifests? I don't know and 773 Why resource #1 should be used for .exe manifests? I don't know and
795 wasn't able to find an explanation for mortals. But it seems to work. 774 wasn't able to find an explanation for mortals. But it seems to work.
796 """ 775 """
797 exefname = self.compiler.executable_filename(self.hgtarget) 776 exefname = self.compiler.executable_filename(self.hgtarget)
805 log.info("running mt.exe to update hg.exe's manifest in-place") 784 log.info("running mt.exe to update hg.exe's manifest in-place")
806 # supplying both -manifest and -inputresource to mt.exe makes 785 # supplying both -manifest and -inputresource to mt.exe makes
807 # it merge the embedded and supplied manifests in the -outputresource 786 # it merge the embedded and supplied manifests in the -outputresource
808 self.spawn( 787 self.spawn(
809 [ 788 [
810 'mt.exe', 789 self.compiler.mt,
811 '-nologo', 790 '-nologo',
812 '-manifest', 791 '-manifest',
813 manfname, 792 manfname,
814 inputresource, 793 inputresource,
815 outputresource, 794 outputresource,