Skip to content

Commit

Permalink
building: fix the references to nested resources in multipackage
Browse files Browse the repository at this point in the history
Fix MERGE() to properly set references to nested resources, i.e.,
with their full shared-package-relative path instead of just basename
(e.g., path/to/shared/pkg:rel/path/to/file as opposed to just
path/to/shared/pkg:file). The latter breaks any resources
(data files, extensions/shared libraries, etc.) that are
located in sub-directories of the shared package.
  • Loading branch information
rokm authored and bwoodsend committed Mar 16, 2021
1 parent 2e4c664 commit 227eac1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 21 additions & 1 deletion PyInstaller/building/api.py
Expand Up @@ -823,8 +823,28 @@ def _set_dependencies(self, analysis, path):
else:
dep_path = self._get_relative_path(path, self._dependencies[tpl[1]])
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
# of the TOC tuple. If entry is EXTENSION, then the
# relative path needs to be reconstructed from the
# name components.
if tpl[2] == 'EXTENSION':
ext_components = tpl[0].split('.')[:-1]
if ext_components:
rel_path = os.path.join(*ext_components)
else:
rel_path = ''
else:
rel_path = os.path.dirname(tpl[0])
# Take filename from 'path' (second component of
# TOC tuple); this way, we don't need to worry about
# suffix of extensions.
filename = os.path.basename(tpl[1])
# Construct the full file path relative to dep_path...
filename = os.path.join(rel_path, filename)
# ...and use it in new DEPENDENCY entry
analysis.dependencies.append(
(":".join((dep_path, os.path.basename(tpl[1]))),
(":".join((dep_path, filename)),
tpl[1],
"DEPENDENCY"))
toc[i] = (None, None, None)
Expand Down
2 changes: 2 additions & 0 deletions news/5606.bugfix.rst
@@ -0,0 +1,2 @@
Fix ``MERGE()`` to properly set references to nested resources with their
full shared-package-relative path instead of just basename.

0 comments on commit 227eac1

Please sign in to comment.