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
5 changes: 4 additions & 1 deletion pex/third_party/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ def iter_root_packages(self, relpath):
yield package

def _filter_names(self, relpath, pattern, group):
# 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://support.pkware.com/display/PKZIP/APPNOTE
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
prefix = self.prefix + ((relpath + '/') if relpath else '')
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
pat = re.compile(r'^{prefix}{pattern}$'
.format(prefix=self.prefix + ((relpath + os.sep) if relpath else ''),
.format(prefix=prefix,
pattern=pattern))

with contextlib.closing(zipfile.ZipFile(self.zipfile_path)) as zf:
Expand Down