Skip to content

Commit

Permalink
archive: fix stored paths when building under MSYS
Browse files Browse the repository at this point in the history
When building CArchive package under MSYS, os.path.sep is Unix-style
forward clash separator that is incompatible with bootloader (which
on Windows expects back slash separators). Therefore, if we are on
Windows and os.path.sep is forward slash, os.path.normpath() in
CTOC.add() needs to be followed by explicit replacement of forward
slashes with back slashes.

Otherwise, bootloader fails to extract nested files from archive in
onefile builds that are created in MSYS environment.
  • Loading branch information
rokm committed Feb 19, 2021
1 parent b9fcbbf commit a07e5ea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion PyInstaller/archive/writers.py
Expand Up @@ -35,7 +35,7 @@
fake_pyc_timestamp
from PyInstaller.loader.pyimod02_archive import PYZ_TYPE_MODULE, PYZ_TYPE_PKG, \
PYZ_TYPE_DATA, PYZ_TYPE_NSPKG
from ..compat import BYTECODE_MAGIC, is_py37
from ..compat import BYTECODE_MAGIC, is_py37, is_win


class ArchiveWriter(object):
Expand Down Expand Up @@ -283,6 +283,10 @@ def add(self, dpos, dlen, ulen, flag, typcd, nm):
# slashes '\\' since on Windows the bootloader works only with back
# slashes.
nm = os.path.normpath(nm)
if is_win and os.path.sep == '/':
# When building under MSYS, the above path normalization
# uses Unix-style separators, so replace them manually.
nm = nm.replace(os.path.sep, '\\')
self.data.append((dpos, dlen, ulen, flag, typcd, nm))


Expand Down

0 comments on commit a07e5ea

Please sign in to comment.