Skip to content

Commit

Permalink
building: simplify PKG.assemble codepath for BINARY and EXTENSION ent…
Browse files Browse the repository at this point in the history
…ries

Remove redundant conditions in if statements to make them easier
to understand, and add comments for the next time when I have
the misfortune of having to poke around this part of the codebase.
  • Loading branch information
rokm committed Nov 23, 2022
1 parent 7d17a91 commit b817760
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions PyInstaller/building/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,21 @@ def assemble(self):
logger.warning("Ignoring non-existent resource %s, meant to be collected as %s", fnm, inm)
continue
if typ in ('BINARY', 'EXTENSION'):
if self.exclude_binaries and typ == 'EXTENSION':
if self.exclude_binaries:
# This is onedir-specific codepath - the EXE and consequently PKG should not be passed the Analysis'
# `datas` and `binaries` TOCs (unless the user messes up the .spec file). However, EXTENSION entries
# might still slip in via `PYZ.dependencies`, which are merged by EXE into its TOC and passed on to
# PKG here. Such entries need to be passed to the parent container (the COLLECT) via
# `PKG.dependencies`.
#
# This codepath formerly performed such pass-through only for EXTENSION entries, but in order to
# keep code simple, we now also do it for BINARY entries. In a sane world, we do not expect to
# encounter them here; but if they do happen to pass through here and we pass them on, the
# container's TOC de-duplication should take care of them (same as with EXTENSION ones, really).
self.dependencies.append((inm, fnm, typ))
elif not self.exclude_binaries:
else:
# This is onefile-specific codepath. The binaries (both EXTENSION and BINARY entries) need to be
# processed using `checkCache` helper.
fnm = checkCache(
fnm,
strip=self.strip_binaries,
Expand Down

0 comments on commit b817760

Please sign in to comment.