-
Notifications
You must be signed in to change notification settings - Fork 533
feat: add pixi reinstall
#3344
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
Merged
ruben-arts
merged 28 commits into
prefix-dev:main
from
Hofer-Julian:feat/pixi-reinstall
Mar 17, 2025
Merged
feat: add pixi reinstall
#3344
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5baed6e
feat: add `pixi reinstall`
Hofer-Julian 06e9567
Add first mostly acceptable test
Hofer-Julian 673148e
Add proper test
Hofer-Julian 46c41de
Fix CLI
Hofer-Julian 90df9b0
Test remaining scenarios
Hofer-Julian f26755e
Hook everything up
Hofer-Julian 50b8b66
Get everything to compile
Hofer-Julian 4a02d55
Get it to compile again
Hofer-Julian 8dadeb6
feat: set refresh strategy for the context
tdejager 00922b5
Adapt for conda
Hofer-Julian 8c59bf6
Adapt tests
Hofer-Julian 6d90eaa
Reorder test a bit
Hofer-Julian 80ccaa6
Only use package names that are actually in our records
Hofer-Julian 597547d
feat: set refresh strategy for the cache
tdejager 5f1881c
fix: test for osx-arm64
tdejager 4c551d1
Fix test
Hofer-Julian a6f0c0b
pixi build rebuild
Hofer-Julian 7cbc7ac
Fix pixi toml
Hofer-Julian 61b7b0f
Fix tests (mostly)
Hofer-Julian 9b13afd
Finalize tests
Hofer-Julian 0874270
Merge branch 'main' into feat/pixi-reinstall
Hofer-Julian e284fca
Adapt CLI docs
Hofer-Julian f9da01b
Adapt string
Hofer-Julian 736c303
Fix string changes
Hofer-Julian d120620
Merge branch 'main' into feat/pixi-reinstall
Hofer-Julian 9c9200f
Fix CLI docs
Hofer-Julian ef9e29a
Merge branch 'main' into feat/pixi-reinstall
ruben-arts 58cbb32
Merge branch 'main' into feat/pixi-reinstall
Hofer-Julian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| use crate::cli::cli_config::WorkspaceConfig; | ||
| use crate::environment::get_update_lock_file_and_prefix; | ||
| use crate::lock_file::UpdateMode; | ||
| use crate::{UpdateLockFileOptions, WorkspaceLocator}; | ||
| use clap::Parser; | ||
| use fancy_display::FancyDisplay; | ||
| use itertools::Itertools; | ||
| use pixi_config::ConfigCli; | ||
|
|
||
| /// Re-install an environment, both updating the lockfile and re-installing the environment. | ||
| /// | ||
| /// This command reinstalls an environment, if the lockfile is not up-to-date it will be updated. | ||
| /// If `--package` is given, only the specified package will be reinstalled. | ||
| /// Otherwise the whole environment will be reinstalled. | ||
| /// | ||
| /// `pixi reinstall` only re-installs one environment at a time, | ||
| /// if you have multiple environments you can select the right one with the `--environment` flag. | ||
| /// If you don't provide an environment, the `default` environment will be re-installed. | ||
| /// | ||
| /// If you want to re-install all environments, you can use the `--all` flag. | ||
| #[derive(Parser, Debug)] | ||
| pub struct Args { | ||
| #[clap(flatten)] | ||
| pub project_config: WorkspaceConfig, | ||
|
|
||
| #[clap(flatten)] | ||
| pub lock_file_usage: super::LockFileUsageConfig, | ||
|
|
||
| /// The environment to install | ||
| #[arg(long, short)] | ||
| pub environment: Option<Vec<String>>, | ||
|
|
||
| #[clap(flatten)] | ||
| pub config: ConfigCli, | ||
|
|
||
| /// Install all environments | ||
| #[arg(long, short, conflicts_with = "environment")] | ||
| pub all: bool, | ||
|
|
||
| /// Specifies the package that should be reinstalled. | ||
| #[arg(num_args = 1.., required = true, id = "PACKAGE")] | ||
| packages: Vec<String>, | ||
| } | ||
|
|
||
| pub async fn execute(args: Args) -> miette::Result<()> { | ||
| let workspace = WorkspaceLocator::for_cli() | ||
| .with_search_start(args.project_config.workspace_locator_start()) | ||
| .locate()? | ||
| .with_cli_config(args.config); | ||
|
|
||
| // Install either: | ||
| // | ||
| // 1. specific environments | ||
| // 2. all environments | ||
| // 3. default environment (if no environments are specified) | ||
| let envs = if let Some(envs) = args.environment { | ||
| envs | ||
| } else if args.all { | ||
| workspace | ||
| .environments() | ||
| .iter() | ||
| .map(|env| env.name().to_string()) | ||
| .collect() | ||
| } else { | ||
| vec![workspace.default_environment().name().to_string()] | ||
| }; | ||
|
|
||
| let mut installed_envs = Vec::with_capacity(envs.len()); | ||
| for env in envs { | ||
| let environment = workspace.environment_from_name_or_env_var(Some(env))?; | ||
|
|
||
| // Update the prefix by installing all packages | ||
| get_update_lock_file_and_prefix( | ||
| &environment, | ||
| UpdateMode::Revalidate, | ||
| UpdateLockFileOptions { | ||
| lock_file_usage: args.lock_file_usage.into(), | ||
| no_install: false, | ||
| max_concurrent_solves: workspace.config().max_concurrent_solves(), | ||
| }, | ||
| ) | ||
| .await?; | ||
|
|
||
| installed_envs.push(environment.name().clone()); | ||
| } | ||
|
|
||
| // Message what's installed | ||
| let detached_envs_message = | ||
| if let Ok(Some(path)) = workspace.config().detached_environments().path() { | ||
| format!(" in '{}'", console::style(path.display()).bold()) | ||
| } else { | ||
| "".to_string() | ||
| }; | ||
|
|
||
| if installed_envs.len() == 1 { | ||
| eprintln!( | ||
| "{}The {} environment has been installed{}.", | ||
| console::style(console::Emoji("✔ ", "")).green(), | ||
| installed_envs[0].fancy_display(), | ||
| detached_envs_message | ||
| ); | ||
| } else { | ||
| eprintln!( | ||
| "{}The following environments have been installed: {}\t{}", | ||
| console::style(console::Emoji("✔ ", "")).green(), | ||
| installed_envs.iter().map(|n| n.fancy_display()).join(", "), | ||
| detached_envs_message | ||
| ); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.