Skip to content

Commit

Permalink
building: fix windows asking for admin with certain filenames by embe…
Browse files Browse the repository at this point in the history
…dding a manifest on 32-bit python

The manifest key `requestedExecutionLevel` is now set every build as well. fixes #4992
  • Loading branch information
Legorooj committed Jul 17, 2020
1 parent f7168c8 commit 1905d2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions PyInstaller/building/api.py
Expand Up @@ -27,7 +27,8 @@
from PyInstaller.building.utils import _check_guts_toc, add_suffix_to_extensions, \
checkCache, strip_paths_in_code, get_code_object, \
_make_clean_directory
from PyInstaller.compat import is_win, is_darwin, is_linux, is_cygwin, exec_command_all
from PyInstaller.compat import is_win, is_darwin, is_linux, is_cygwin, \
exec_command_all, is_64bits
from PyInstaller.depend import bindepend
from PyInstaller.depend.analysis import get_bootstrap_modules
from PyInstaller.depend.utils import is_path_to_egg
Expand Down Expand Up @@ -527,7 +528,7 @@ def assemble(self):
raise SystemExit(_MISSING_BOOTLOADER_ERRORMSG)

if is_win and (self.icon or self.versrsrc or self.resources or
self.uac_admin or self.uac_uiaccess):
self.uac_admin or self.uac_uiaccess or not is_64bits):
fd, tmpnm = tempfile.mkstemp(prefix=os.path.basename(exe) + ".",
dir=CONF['workpath'])
# need to close the file, otherwise copying resources will fail
Expand Down
2 changes: 2 additions & 0 deletions PyInstaller/utils/win32/winmanifest.py
Expand Up @@ -1061,6 +1061,8 @@ def create_manifest(filename, manifest, console, uac_admin=False, uac_uiaccess=F
)
if uac_admin:
manifest.requestedExecutionLevel = 'requireAdministrator'
else:
manifest.requestedExecutionLevel = 'asInvoker'
if uac_uiaccess:
manifest.uiAccess = True

Expand Down
1 change: 1 addition & 0 deletions news/4992.bugfix.rst
@@ -0,0 +1 @@
(Windows) When building with 32-bit python in onefile mode, set the ``requestedExecutionLevel`` manifest key every time and embed the manifest.

0 comments on commit 1905d2b

Please sign in to comment.