feat: add environment variable to disable writing installer metadata files (#8877)

## Summary

This change introduces the `UV_NO_INSTALLER_METADATA` environment
variable
as a way to opt out of the extra installer metadata files that `uv` is
creating.

This is important to achieve reproducible builds in distribution
packaging, allowing to replace usage of
[installer](https://pypi.org/project/installer) with `uv pip install`.

At the time of writing these files are:
- `uv_cache.json`
    Contains timestamps which are non-reproducible.
    These hashes also leak in to the `RECORD` file.

- `direct_url.json`
    Contains the path to the installed wheel.
While not non-reproducible it's not required for distribution packaging.

- `INSTALLER`
Again, not non-reproducible, but of no value in distribution packaging.

## Test Plan

Automated test added.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
adisbladis 2024-12-04 01:29:33 +00:00 committed by GitHub
parent ae033e2d3b
commit 28d4ef35f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 162 additions and 13 deletions

View file

@ -256,6 +256,10 @@ pub struct GlobalArgs {
#[arg(global = true, long, env = EnvVars::UV_NO_PROGRESS, value_parser = clap::builder::BoolishValueParser::new())]
pub no_progress: bool,
/// Skip writing `uv` installer metadata files (e.g., `INSTALLER`, `REQUESTED`, and `direct_url.json`) to site-packages `.dist-info` directories.
#[arg(global = true, long, hide = true, env = EnvVars::UV_NO_INSTALLER_METADATA, value_parser = clap::builder::BoolishValueParser::new())]
pub no_installer_metadata: bool,
/// Change to the given directory prior to running the command.
///
/// Relative paths are resolved with the given directory as the base.