Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include option to save failed build environments #157

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Prev Previous commit
Next Next commit
Merge branch 'main' into feat/save-failed-builds
  • Loading branch information
tdejager committed Jan 22, 2024
commit 6692479f339543f6af4e3a62551a4ed5a3ee62ac
18 changes: 12 additions & 6 deletions crates/rattler_installs_packages/src/wheel_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ mod build_environment;
mod wheel_cache;

use fs_err as fs;
use std::io::{Read, Seek};

use std::collections::HashSet;

use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use std::{collections::HashMap, path::PathBuf};

use parking_lot::Mutex;
use pep508_rs::{MarkerEnvironment, Requirement};

use crate::python_env::VEnvError;
use crate::python_env::{ParsePythonInterpreterVersionError, PythonInterpreterVersion, VEnvError};
use crate::resolve::{OnWheelBuildFailure, ResolveOptions, SDistResolution};
use crate::types::{NormalizedPackageName, ParseArtifactNameError, WheelFilename};
use crate::wheel_builder::build_environment::BuildEnvironment;
Expand Down Expand Up @@ -58,6 +58,9 @@ pub struct WheelBuilder<'db, 'i> {
/// This is used to save build environments for debugging
/// only if the `save_on_failure` option is set in resolve options
saved_build_envs: Mutex<HashSet<PathBuf>>,

/// Python interpreter version
python_version: PythonInterpreterVersion,
}

/// An error that can occur while building a wheel
Expand Down Expand Up @@ -150,7 +153,13 @@ impl<'db, 'i> WheelBuilder<'db, 'i> {
resolve_options,
env_variables,
saved_build_envs: Mutex::new(HashSet::new()),
}
python_version,
})
}

/// Get the python interpreter version
pub fn python_version(&self) -> &PythonInterpreterVersion {
&self.python_version
}

/// Get a prepared virtualenv for building a wheel (or extracting metadata) from an `[SDist]`
Expand Down Expand Up @@ -312,14 +321,11 @@ impl<'db, 'i> WheelBuilder<'db, 'i> {
}

// Setup a new virtualenv for building the wheel or use an existing
println!("A");
let build_environment = self.setup_build_venv(sdist).await?;
println!("B");
// Capture the result of the build
// to handle different failure modes
let result = self.build_wheel_internal(&build_environment, sdist).await;

println!("C");
self.handle_build_failure(result, &build_environment, sdist.name())
}

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.