Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depend/utils: strip paths from modules collected into base_library.zip #5564

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion PyInstaller/depend/utils.py
Expand Up @@ -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'.
Expand Down Expand Up @@ -102,7 +106,8 @@ def create_py3_base_library(libzip_filename, graph):
fc.write(source_hash)
else:
fc.write(struct.pack('<II', timestamp, size))
marshal.dump(mod.code, fc)
code = strip_paths_in_code(mod.code) # Strip paths
marshal.dump(code, fc)
# Use a ZipInfo to set timestamp for deterministic build
info = zipfile.ZipInfo(new_name)
zf.writestr(info, fc.getvalue())
Expand Down
2 changes: 2 additions & 0 deletions news/5563.bugfix.rst
@@ -0,0 +1,2 @@
Strip absolute paths from ``.pyc`` modules collected into ``base_library.zip``
to enable reproducible builds that are invariant to Python install location.