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

When iterating over Zipfiles, always use the Unix file separator to fix a Windows issue #638

Merged
8 changes: 4 additions & 4 deletions pex/third_party/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ def iter_root_packages(self, relpath):
yield package

def _filter_names(self, relpath, pattern, group):
pat = re.compile(r'^{prefix}{pattern}$'
.format(prefix=self.prefix + ((relpath + os.sep) if relpath else ''),
pattern=pattern))

# We use '/' here instead of os.sep because the zip file format spec specifies that paths must use forward slashes.
# See section 4.4.17 of https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
relpath_pat = '{}/'.format(relpath) if relpath else ''
pat = re.compile(r'^{}{}{}$'.format(self.prefix, relpath_pat, pattern))
with contextlib.closing(zipfile.ZipFile(self.zipfile_path)) as zf:
for name in zf.namelist():
match = pat.match(name)
Expand Down