Reduce visibility of some methods in wheel.rs (#1125)

This commit is contained in:
Charlie Marsh 2024-01-26 13:34:51 -08:00 committed by GitHub
parent 0cdde8949f
commit 06024653f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 9 deletions

View file

@ -19,8 +19,7 @@ pub use record::RecordEntry;
pub use script::Script;
pub use uninstall::{uninstall_wheel, Uninstall};
pub use wheel::{
get_script_launcher, install_wheel, parse_key_value_file, read_record_file, relative_to,
SHEBANG_PYTHON,
install_wheel, parse_key_value_file, read_record_file, relative_to, SHEBANG_PYTHON,
};
mod install_location;

View file

@ -50,7 +50,7 @@ const LAUNCHER_X86_64_CONSOLE: &[u8] = &[];
/// Wrapper script template function
///
/// <https://github.com/pypa/pip/blob/7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4/src/pip/_vendor/distlib/scripts.py#L41-L48>
pub fn get_script_launcher(module: &str, import_name: &str, shebang: &str) -> String {
fn get_script_launcher(module: &str, import_name: &str, shebang: &str) -> String {
format!(
r##"{shebang}
# -*- coding: utf-8 -*-
@ -129,10 +129,7 @@ fn parse_scripts<R: Read + Seek>(
/// <https://github.com/richo/hashing-copy/blob/d8dd2fdb63c6faf198de0c9e5713d6249cbb5323/src/lib.rs#L10-L52>
/// which in turn got it from std
/// <https://doc.rust-lang.org/1.58.0/src/std/io/copy.rs.html#128-156>
pub(crate) fn copy_and_hash(
reader: &mut impl Read,
writer: &mut impl Write,
) -> io::Result<(u64, String)> {
fn copy_and_hash(reader: &mut impl Read, writer: &mut impl Write) -> io::Result<(u64, String)> {
// TODO: Do we need to support anything besides sha256?
let mut hasher = Sha256::new();
// Same buf size as std. Note that this number is important for performance
@ -276,7 +273,7 @@ fn unpack_wheel_files<R: Read + Seek>(
Ok(extracted_paths)
}
pub(crate) fn get_shebang(location: &InstallLocation<impl AsRef<Path>>) -> String {
fn get_shebang(location: &InstallLocation<impl AsRef<Path>>) -> String {
let path = location.python().to_string_lossy().to_string();
let path = if cfg!(windows) {
// https://stackoverflow.com/a/50323079
@ -405,7 +402,7 @@ pub(crate) fn write_script_entrypoints(
Ok(())
}
pub(crate) fn bin_rel() -> PathBuf {
fn bin_rel() -> PathBuf {
if cfg!(windows) {
// windows doesn't have the python part, only Lib/site-packages
Path::new("..").join("..").join("Scripts")