Skip to content

Commit

Permalink
building: prevent MERGE from creating self-references for duplicated …
Browse files Browse the repository at this point in the history
…TOC entries

A duplicated TOC entry (e.g., a resource being once listed as binary
in Analysis.binaries and once as data in Analysis.datas) in the
first Analysis being passed to MERGE() ends up generating
a spurious DEPENDENCY entry with a self-reference to itself.

Therefore, the dependencies TOC of the primary Analysis object ends
up non-empty, and if passed to EXE(), results in a non-functional
executable.
  • Loading branch information
rokm authored and bwoodsend committed Mar 27, 2021
1 parent 937d8a3 commit 7d8ffec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions PyInstaller/building/api.py
Expand Up @@ -822,6 +822,17 @@ def _set_dependencies(self, analysis, path):
self._dependencies[tpl[1]] = path
else:
dep_path = self._get_relative_path(path, self._dependencies[tpl[1]])
# Ignore references that point to the origin package.
# This can happen if the same resource is listed
# multiple times in TOCs (e.g., once as binary and
# once as data).
if dep_path.endswith(path):
logger.debug("Ignoring self-reference of %s for %s, "
"located in %s - duplicated TOC entry?",
tpl[1], path, dep_path)
# Clear the entry as it is a duplicate.
toc[i] = (None, None, None)
continue
logger.debug("Referencing %s to be a dependecy for %s, located in %s" % (tpl[1], path, dep_path))
# Determine the path relative to dep_path (i.e, within
# the target directory) from the 'name' component
Expand Down
2 changes: 2 additions & 0 deletions news/5652.bugfix.rst
@@ -0,0 +1,2 @@
Prevent ``MERGE`` (multipackage) from creating self-references for
duplicated TOC entries.

0 comments on commit 7d8ffec

Please sign in to comment.