From 5d2433a50975c2ddb2a715942d464a934f4e54c8 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Fri, 5 Mar 2021 23:14:16 +0100 Subject: [PATCH] building: fix the references to nested resources in multipackage 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. --- PyInstaller/building/api.py | 22 +++++++++++++++++++++- news/5606.bugfix.rst | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 news/5606.bugfix.rst diff --git a/PyInstaller/building/api.py b/PyInstaller/building/api.py index 02d5c30a9fe..2b00dfaf59b 100644 --- a/PyInstaller/building/api.py +++ b/PyInstaller/building/api.py @@ -824,8 +824,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) diff --git a/news/5606.bugfix.rst b/news/5606.bugfix.rst new file mode 100644 index 00000000000..d6e59790e05 --- /dev/null +++ b/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.