Write direct_url.json in wheel installer (#337)

## Summary

This PR just adds the logic in `install-wheel-rs` to write
`direct_url.json`. We're not actually taking advantage of it yet (or
wiring it through) in Puffin.

Part of https://github.com/astral-sh/puffin/issues/332.
This commit is contained in:
Charlie Marsh 2023-11-06 09:09:28 -08:00 committed by GitHub
parent 9b077f3d0f
commit d9bcfafa16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 110 additions and 20 deletions

View file

@ -15,7 +15,7 @@ use crate::wheel::{
extra_dist_info, install_data, parse_wheel_version, read_scripts_from_section,
write_script_entrypoints,
};
use crate::{read_record_file, Error, Script};
use crate::{read_record_file, DirectUrl, Error, Script};
/// Install the given wheel to the given venv
///
@ -27,6 +27,7 @@ use crate::{read_record_file, Error, Script};
pub fn install_wheel(
location: &InstallLocation<impl AsRef<Path>>,
wheel: impl AsRef<Path>,
direct_url: Option<&DirectUrl>,
link_mode: LinkMode,
) -> Result<(), Error> {
let root = location.venv_root();
@ -105,8 +106,13 @@ pub fn install_wheel(
}
debug!(name, "Writing extra metadata");
extra_dist_info(&site_packages, &dist_info_prefix, true, &mut record)?;
extra_dist_info(
&site_packages,
&dist_info_prefix,
true,
direct_url,
&mut record,
)?;
debug!(name, "Writing record");
let mut record_writer = csv::WriterBuilder::new()