diff --git a/PyInstaller/building/api.py b/PyInstaller/building/api.py index c1efe37560..5515279899 100644 --- a/PyInstaller/building/api.py +++ b/PyInstaller/building/api.py @@ -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 diff --git a/news/5652.bugfix.rst b/news/5652.bugfix.rst new file mode 100644 index 0000000000..d4707433e7 --- /dev/null +++ b/news/5652.bugfix.rst @@ -0,0 +1,2 @@ +Prevent ``MERGE`` (multipackage) from creating self-references for +duplicated TOC entries.