Created
December 4, 2014 15:57
-
-
Save raincode00/36244ef62d4b13d6ba40 to your computer and use it in GitHub Desktop.
Embeds manifest file in PyInstaller's windows bootloaders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Embeds manifest file in PyInstaller's windows bootloaders. | |
""" | |
import os | |
import subprocess | |
from distutils import msvccompiler | |
from tempfile import NamedTemporaryFile | |
def embed_manifest(manifest, target_exe): | |
msvc = msvccompiler.MSVCCompiler() | |
msvc.initialize() | |
mt = msvc.find_exe("mt.exe") | |
subprocess.call([mt, "-manifest", manifest, "-outputresource:%s;1"%target_exe]) | |
if __name__ == "__main__": | |
manifest = """<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | |
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | |
<security> | |
<requestedPrivileges> | |
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> | |
</requestedPrivileges> | |
</security> | |
</trustInfo> | |
</assembly>""" | |
working_dir = os.path.dirname(os.path.realpath(__file__)) | |
manifest_file = NamedTemporaryFile(delete=False) | |
manifest_file.write(manifest) | |
manifest_file.close() | |
platforms = [ | |
"Windows-32bit", | |
"Windows-64bit", | |
] | |
exes = [ | |
"run.exe", | |
"run_d.exe", | |
"runw.exe", | |
"runw_d.exe", | |
] | |
for p in platforms: | |
for exe in exes: | |
exe = os.path.join(working_dir, "bootloader", p, exe) | |
embed_manifest(manifest_file.name, exe) | |
os.remove(manifest_file.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment