Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only update resources when necessary to keep signature valid #3323

Merged
merged 2 commits into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions PyInstaller/building/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ def applyRedirects(manifest, redirects):
:return:
:rtype:
"""
redirecting = False
for binding in redirects:
for dep in manifest.dependentAssemblies:
if match_binding_redirect(dep, binding):
logger.info("Redirecting %s version %s -> %s",
binding.name, dep.version, binding.newVersion)
dep.version = binding.newVersion
redirecting = True
return redirecting

def checkCache(fnm, strip=False, upx=False, dist_nm=None):
"""
Expand Down Expand Up @@ -287,7 +290,8 @@ def checkCache(fnm, strip=False, upx=False, dist_nm=None):
logger.error("From file %s", cachedfile, exc_info=1)
else:
# optionally change manifest to private assembly
if CONF.get('win_private_assemblies', False):
private = CONF.get('win_private_assemblies', False)
if private:
if manifest.publicKeyToken:
logger.info("Changing %s into a private assembly",
os.path.basename(fnm))
Expand All @@ -298,14 +302,15 @@ def checkCache(fnm, strip=False, upx=False, dist_nm=None):
# Exclude common-controls which is not bundled
if dep.name != "Microsoft.Windows.Common-Controls":
dep.publicKeyToken = None
applyRedirects(manifest, redirects)
try:
manifest.update_resources(os.path.abspath(cachedfile),
[name],
[language])
except Exception as e:
logger.error(os.path.abspath(cachedfile))
raise
redirecting = applyRedirects(manifest, redirects)
if redirecting or private:
try:
manifest.update_resources(os.path.abspath(cachedfile),
[name],
[language])
except Exception as e:
logger.error(os.path.abspath(cachedfile))
raise

if cmd:
try:
Expand Down