Improve install instrumentation (#829)

Add tracing spans to different phases of the wheel installation.
This commit is contained in:
konsti 2024-01-08 11:13:59 +01:00 committed by GitHub
parent 2d4743d782
commit 3f587156ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -6,7 +6,7 @@ use std::path::Path;
use configparser::ini::Ini;
use fs_err as fs;
use fs_err::File;
use tracing::{debug, info_span};
use tracing::{debug, instrument};
use pypi_types::DirectUrl;
@ -24,6 +24,7 @@ use crate::{read_record_file, Error, Script};
/// <https://packaging.python.org/en/latest/specifications/binary-distribution-format/#installing-a-wheel-distribution-1-0-py32-none-any-whl>
///
/// Wheel 1.0: <https://www.python.org/dev/peps/pep-0427/>
#[instrument(skip_all, fields(wheel = %wheel.as_ref().display()))]
pub fn install_wheel(
location: &InstallLocation<impl AsRef<Path>>,
wheel: impl AsRef<Path>,
@ -52,8 +53,6 @@ pub fn install_wheel(
let metadata = dist_info_metadata(&dist_info_prefix, &wheel)?;
let (name, _version) = parse_metadata(&dist_info_prefix, &metadata)?;
let _my_span = info_span!("install_wheel", name);
// We're going step by step though
// https://packaging.python.org/en/latest/specifications/binary-distribution-format/#installing-a-wheel-distribution-1-0-py32-none-any-whl
// > 1.a Parse distribution-1.0.dist-info/WHEEL.
@ -231,6 +230,7 @@ impl Default for LinkMode {
impl LinkMode {
/// Extract a wheel by linking all of its files into site packages.
#[instrument(skip_all)]
pub fn link_wheel_files(
self,
site_packages: impl AsRef<Path>,

View file

@ -432,6 +432,7 @@ pub(crate) fn parse_wheel_version(wheel_text: &str) -> Result<(), Error> {
///
/// 2.f Compile any installed .py to .pyc. (Uninstallers should be smart enough to remove .pyc
/// even if it is not mentioned in RECORD.)
#[instrument(skip_all)]
fn bytecode_compile(
site_packages: &Path,
unpacked_paths: Vec<PathBuf>,
@ -723,6 +724,7 @@ fn install_script(
/// Move the files from the .data directory to the right location in the venv
#[allow(clippy::too_many_arguments)]
#[instrument(skip_all)]
pub(crate) fn install_data(
venv_root: &Path,
site_packages: &Path,