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

dep: Update installer to 0.7.0 to enable RECORD validation #1784

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/1784.dep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update `installer` to `0.7.0` and emit a warning if the RECORD validation fails.
10 changes: 5 additions & 5 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"shellingham>=1.3.2",
"python-dotenv>=0.15",
"resolvelib>=0.9,<0.10",
"installer<0.7,>=0.6",
"installer<0.8,>=0.7",
"cachecontrol[filecache]>=0.12.11",
"tomli>=1.1.0; python_version < \"3.11\"",
"typing-extensions; python_version < \"3.8\"",
Expand Down
12 changes: 12 additions & 0 deletions src/pdm/installers/installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import itertools
import json
import os
import warnings
import zipfile
from functools import lru_cache
from pathlib import Path
Expand All @@ -14,6 +15,7 @@
from installer.exceptions import InvalidWheelSource
from installer.records import RecordEntry
from installer.sources import WheelFile as _WheelFile
from installer.sources import _WheelFileValidationError

from pdm.compat import cached_property
from pdm.installers.packages import CachedPackage
Expand Down Expand Up @@ -247,6 +249,16 @@ def _install_wheel(
Return the .dist-info path
"""
with WheelFile.open(wheel) as source:
try:
source.validate_record()
except _WheelFileValidationError as e:
formatted_issues = "\n".join(e.issues)
warning = (
f"Validation of the RECORD file of {wheel} failed."
" Please report to the maintainers of that package so they can fix"
f" their build process. Details:\n{formatted_issues}\n"
)
warnings.warn(warning, UserWarning, stacklevel=2)
root_scheme = _process_WHEEL_file(source)
source.exclude = excludes
if additional_contents:
Expand Down