Skip to content

Commit

Permalink
Fix handling of data files when creating venvs. (#1632)
Browse files Browse the repository at this point in the history
This uses the RECORD as the basis for determining which files to copy
and where they belong, fixing the issues with data files not being
properly located.

Fixes #1630
  • Loading branch information
jsirois authored Feb 28, 2022
1 parent f931bef commit 70a2cad
Show file tree
Hide file tree
Showing 35 changed files with 1,229 additions and 256 deletions.
20 changes: 19 additions & 1 deletion pex/dist_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,26 @@ def find_dist_info_file(
# combo of `-`, `_`, and `.` as name component separators.
project_name_pattern = re.sub(r"[-_.]+", "[-_.]+", project_name)

# The relevant PEP for versions is https://www.python.org/dev/peps/pep-0440 which does not allow
# a `-` in modern versions but also stipulates that all versions (legacy) must be handled. It
# turns out wheel normalizes `-` to `_` and Pip has had to deal with this:
# https://github.com/pypa/pip/issues/1150
#
# We also deal with this, accepting either `-` or `_` when a `-` is expected.
version_pattern = re.sub(
r"(?P<left>[^-]+)-(?P<right>[^-]+)",
lambda match: "{left}[-_]{right}".format(
left=re.escape(match.group("left")), right=re.escape(match.group("right"))
),
version,
)
if version_pattern == version:
version_pattern = re.escape(version)

wheel_metadata_pattern = "^{}$".format(
os.path.join("{}-{}.dist-info".format(project_name_pattern, re.escape(version)), filename)
os.path.join(
"{}-{}\\.dist-info".format(project_name_pattern, version_pattern), re.escape(filename)
)
)
wheel_metadata_re = re.compile(wheel_metadata_pattern, re.IGNORECASE)
for item in listing:
Expand Down
Loading

0 comments on commit 70a2cad

Please sign in to comment.