Skip to content

Commit

Permalink
fix: allowing solving for different platforms (#1101)
Browse files Browse the repository at this point in the history
Fixes #1082

Checking if the current machine meets the project requirements is only
really required when using `run` or `shell`. This PR moves the logic to
check if the system meets the minimum system requirements to those
specific CLI commands. This allows you to create lock-files for other
platforms than your own. (as long as you dont have pypi dependencies)

Co-authored-by: Ruben Arts <ruben.arts@hotmail.com>
  • Loading branch information
baszalmstra and ruben-arts authored Apr 2, 2024
1 parent 28b926f commit 6592e5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ pub async fn get_task_env<'p>(
lock_file_derived_data: &mut LockFileDerivedData<'p>,
environment: &Environment<'p>,
) -> miette::Result<HashMap<String, String>> {
// Make sure the system requirements are met
verify_current_platform_has_required_virtual_packages(environment).into_diagnostic()?;

// Ensure there is a valid prefix
lock_file_derived_data.prefix(environment).await?;

Expand Down
3 changes: 3 additions & 0 deletions src/cli/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::unix::PtySession;

use crate::cli::LockFileUsageArgs;
use crate::project::manifest::EnvironmentName;
use crate::project::virtual_packages::verify_current_platform_has_required_virtual_packages;
#[cfg(target_family = "windows")]
use rattler_shell::shell::CmdExe;

Expand Down Expand Up @@ -208,6 +209,8 @@ pub async fn execute(args: Args) -> miette::Result<()> {
.environment(&environment_name)
.ok_or_else(|| miette::miette!("unknown environment '{environment_name}'"))?;

verify_current_platform_has_required_virtual_packages(&environment).into_diagnostic()?;

let prompt_name = match environment_name {
EnvironmentName::Default => project.name().to_string(),
EnvironmentName::Named(name) => format!("{}:{}", project.name(), name),
Expand Down
5 changes: 0 additions & 5 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::{
project::{
grouped_environment::GroupedEnvironment,
manifest::{EnvironmentName, SystemRequirements},
virtual_packages::verify_current_platform_has_required_virtual_packages,
Environment,
},
Project,
Expand Down Expand Up @@ -153,10 +152,6 @@ pub async fn sanity_check_project(project: &Project) -> miette::Result<()> {
// Sanity check of prefix location
verify_prefix_location_unchanged(project.default_environment().dir().as_path()).await?;

// Make sure the system requirements are met
verify_current_platform_has_required_virtual_packages(&project.default_environment())
.into_diagnostic()?;

// TODO: remove on a 1.0 release
// Check for old `env` folder as we moved to `envs` in 0.13.0
let old_pixi_env_dir = project.pixi_dir().join("env");
Expand Down

0 comments on commit 6592e5f

Please sign in to comment.