diff --git a/crates/uv-install-wheel/src/wheel.rs b/crates/uv-install-wheel/src/wheel.rs index a349b8a79..8218f75ae 100644 --- a/crates/uv-install-wheel/src/wheel.rs +++ b/crates/uv-install-wheel/src/wheel.rs @@ -604,7 +604,7 @@ pub(crate) fn write_file_recorded( let hash = Sha256::new().chain_update(content.as_ref()).finalize(); let encoded_hash = format!("sha256={}", BASE64URL_NOPAD.encode(&hash)); record.push(RecordEntry { - path: relative_path.display().to_string(), + path: relative_path.portable_display().to_string(), hash: Some(encoded_hash), size: Some(content.as_ref().len() as u64), }); @@ -741,7 +741,8 @@ mod test { use crate::Error; use super::{ - get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file, Script, + get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file, + write_installer_metadata, RecordEntry, Script, }; #[test] @@ -1016,4 +1017,36 @@ mod test { Ok(()) } + + #[test] + fn test_write_installer_metadata() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let site_packages = temp_dir.path(); + let mut record: Vec = Vec::new(); + temp_dir + .child("foo-0.1.0.dist-info") + .create_dir_all() + .unwrap(); + write_installer_metadata( + site_packages, + "foo-0.1.0", + true, + None, + None, + Some("uv"), + &mut record, + ) + .unwrap(); + let expected = [ + "foo-0.1.0.dist-info/REQUESTED", + "foo-0.1.0.dist-info/INSTALLER", + ] + .map(ToString::to_string) + .to_vec(); + let actual = record + .into_iter() + .map(|entry| entry.path) + .collect::>(); + assert_eq!(expected, actual); + } } diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index 94e67a6cc..081be9a72 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -418,12 +418,11 @@ pub fn entrypoint_paths( }; let absolute_path = layout.scheme.scripts.join(path_in_scripts); - let script_name = entry - .path - .rsplit(std::path::MAIN_SEPARATOR) - .next() - .unwrap_or(&entry.path) - .to_string(); + let script_name = relative_path + .file_name() + .and_then(|filename| filename.to_str()) + .map(ToString::to_string) + .unwrap_or(entry.path); entrypoints.push((script_name, absolute_path)); }