# HG changeset patch # User Matt Harbison # Date 2022-07-18 23:18:00 # Node ID ece490b02a9b4eef512dbdb6e0b97b91f3a6c943 # Parent 747c4fc20886a867e1ff7c6a1d05327537a5421d setup: use the full executable manifest from `python.exe` The manifest embedded by the build process (before the string here is added) already accounts for the `` setting. (Note that the PyOxidizer build is missing this, so it will likely trigger the UAC escalation prompt on each run.) However, using `mt.exe` to merge the fragment with what is already in the manifest seems to strip all whitespace, making it unreadable. Since Mercurial can be run via `python.exe`, it makes sense that we would have the same manifest settings (like the supported OS list), though I'm unaware of any functionality this enables. It also has the nice effect of making the content readable from a resource editor. The manifest comes from python 3.9.12. Note that this seems to strip the `` declaration when viewed with ResourceHacker 5.1.7, but this was also the state of things with the previous commit, and `mt.exe "-inputresource:hg.exe;#1" -out:extracted` does contain the declaration and the BOM in both cases. No idea why this differs from other executables. diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -667,16 +667,51 @@ class buildhgextindex(Command): class buildhgexe(build_ext): description = 'compile hg.exe from mercurial/exewrapper.c' - LONG_PATHS_MANIFEST = """ - - - - - true - - - """ + LONG_PATHS_MANIFEST = """\ + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + +""" def initialize_options(self): build_ext.initialize_options(self) @@ -776,21 +811,18 @@ class buildhgexe(build_ext): exefname = self.compiler.executable_filename(self.hgtarget) fdauto, manfname = tempfile.mkstemp(suffix='.hg.exe.manifest') os.close(fdauto) - with open(manfname, 'w') as f: + with open(manfname, 'w', encoding="UTF-8") as f: f.write(self.LONG_PATHS_MANIFEST) log.info("long paths manifest is written to '%s'" % manfname) - inputresource = '-inputresource:%s;#1' % exefname outputresource = '-outputresource:%s;#1' % exefname log.info("running mt.exe to update hg.exe's manifest in-place") - # supplying both -manifest and -inputresource to mt.exe makes - # it merge the embedded and supplied manifests in the -outputresource + self.spawn( [ self.compiler.mt, '-nologo', '-manifest', manfname, - inputresource, outputresource, ] )