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

fix: support adding dependencies for project's unsupported platforms #668

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
consts, default_authenticated_client, install, install_pypi, lock_file, prefix::Prefix,
progress, Project,
};
use miette::{Context, IntoDiagnostic, LabeledSpan};
use miette::{Context, IntoDiagnostic};

use crate::lock_file::lock_file_satisfies_project;
use crate::project::virtual_packages::verify_current_platform_has_required_virtual_packages;
Expand Down Expand Up @@ -57,25 +57,15 @@ fn create_prefix_location_file(prefix_file: &Path) -> miette::Result<()> {
/// 1. It verifies that the prefix location is unchanged.
/// 2. It verifies that the project supports the current platform.
/// 3. It verifies that the system requirements are met.
pub fn sanity_check_project(project: &Project) -> miette::Result<()> {
pub fn sanity_check_project(project: &Project, no_install: &mut bool) -> miette::Result<()> {
ruben-arts marked this conversation as resolved.
Show resolved Hide resolved
// Sanity check of prefix location
verify_prefix_location_unchanged(project.pixi_dir().join(consts::PREFIX_FILE_NAME).as_path())?;

// Make sure the project supports the current platform
let platform = Platform::current();
if !project.platforms().contains(&platform) {
let span = project.manifest.parsed.project.platforms.span();
return Err(miette::miette!(
help = format!(
"The project needs to be configured to support your platform ({platform})."
),
labels = vec![LabeledSpan::at(
span.unwrap_or_default(),
format!("add '{platform}' here"),
)],
"the project is not configured for your current platform"
)
.with_source_code(project.manifest_named_source()));
*no_install = true;
tracing::warn!("Adding dependency for unsupported platform ({platform}).")
orhun marked this conversation as resolved.
Show resolved Hide resolved
}

// Make sure the system requirements are met
Expand Down Expand Up @@ -124,11 +114,11 @@ impl LockFileUsage {
pub async fn get_up_to_date_prefix(
project: &Project,
usage: LockFileUsage,
no_install: bool,
mut no_install: bool,
sparse_repo_data: Option<Vec<SparseRepoData>>,
) -> miette::Result<Prefix> {
// Make sure the project is in a sane state
sanity_check_project(project)?;
sanity_check_project(project, &mut no_install)?;

// Start loading the installed packages in the background
let prefix = Prefix::new(project.environment_dir())?;
Expand Down
Loading