From de4097d923de211a20f9c535a06d533db9278331 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Thu, 18 Feb 2021 13:49:11 +0100 Subject: [PATCH] depend/utils: strip paths from modules collected into base_library.zip Strip paths from modules collected into base_library.zip, to enable reproducible builds regardless of python's install location. Fixes #5563. --- PyInstaller/depend/utils.py | 7 ++++++- news/5563.bugfix.rst | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 news/5563.bugfix.rst diff --git a/PyInstaller/depend/utils.py b/PyInstaller/depend/utils.py index 95846f39d5..bb293859cb 100644 --- a/PyInstaller/depend/utils.py +++ b/PyInstaller/depend/utils.py @@ -49,6 +49,10 @@ def create_py3_base_library(libzip_filename, graph): modules is necessary to have on PYTHONPATH for initializing libpython3 in order to run the frozen executable with Python 3. """ + # Import strip_paths_in_code locally to avoid cyclic import between + # building.utils and depend.utils (this module); building.utils + # imports depend.bindepend, which in turn imports depend.utils. + from ..building.utils import strip_paths_in_code # Construct regular expression for matching modules that should be bundled # into base_library.zip. # Excluded are plain 'modules' or 'submodules.ANY_NAME'. @@ -102,7 +106,8 @@ def create_py3_base_library(libzip_filename, graph): fc.write(source_hash) else: fc.write(struct.pack('