Skip to content

Commit

Permalink
building: util: Only update resources of cached files when necessary.
Browse files Browse the repository at this point in the history
This fixes #2526. Pyinstaller is updating the resources for python35.dll and makes its signature invalid. This then prevents that dll from being signed with the 'signtool' utility (which then can have more consequences, like the inability to publish the app to a repository where signing is mandatory).

In this commit, the resource update is skipped if it is not necessary, i.e. it is only performed if there have been some redirections or if the dll has been made private.
  • Loading branch information
tlecomte authored and htgoebel committed Feb 27, 2018
1 parent 70b7d25 commit 2611919
Showing 1 changed file with 14 additions and 9 deletions.
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 @@ -299,7 +302,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 @@ -310,14 +314,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

0 comments on commit 2611919

Please sign in to comment.