pypa / installer

A low-level library for installing from a Python wheel distribution.
https://installer.readthedocs.io/
MIT License
126 stars 52 forks source link

Optionally don't write a RECORD file #246

Open rossburton opened 1 week ago

rossburton commented 1 week ago

The RECORD file is a partial list of files in the wheel and their hashes. Quoting from PEP 0491:

RECORD is a list of (almost) all the files in the wheel and their secure hashes. Unlike PEP 376, every file except RECORD, which cannot contain a hash of itself, must include its hash. The hash algorithm must be sha256 or better; specifically, md5 and sha1 are not permitted, as signed wheel files rely on the strong hashes in RECORD to validate the integrity of the archive.

It's incredibly useful to have this inside the wheel at installation time, but if the target is not going to be managed by a python package manager then it's just pointless. For example, a Linux distribution package of Python won't need the RECORD file: it already has tooling for the list of files and their hashes.

The rationale to remove the file entirely instead of just ignoring it is that when the file is present, pip thinks it can use it. This means sudo pip can remove files from the system packages, which is asking for trouble.

Interesting prior art:

Instead of these tools having to go in and remove files, it would be nice if installer had an option to stop it writing the file in the first place.

rossburton commented 1 week ago

Fedora also removes the RECORD file: https://src.fedoraproject.org/rpms/pyproject-rpm-macros/blob/rawhide/f/macros.pyproject#_105.