Skip to content

Commit

Permalink
Adding local pip-review (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
MonstrousOgre authored May 20, 2023
1 parent f06b7c0 commit 54301a6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@
#nix_arguments = "--flake"

[python]
#enable_pip_review = true ###disabled by default
#enable_pipupgrade = true ###disabled by default
#enable_pip_review = true ###disabled by default
#enable_pip_review_local = true ###disabled by default
#enable_pipupgrade = true ###disabled by default

[windows]
# Manually select Windows updates
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub enum Step {
Pearl,
Pip3,
PipReview,
PipReviewLocal,
Pipupgrade,
Pipx,
Pkg,
Expand Down Expand Up @@ -200,6 +201,7 @@ pub struct Windows {
#[serde(deny_unknown_fields)]
pub struct Python {
enable_pip_review: Option<bool>,
enable_pip_review_local: Option<bool>,
enable_pipupgrade: Option<bool>,
}

Expand Down Expand Up @@ -1138,6 +1140,14 @@ impl Config {
.and_then(|python| python.enable_pip_review)
.unwrap_or(false);
}
pub fn enable_pip_review_local(&self) -> bool {
return self
.config_file
.python
.as_ref()
.and_then(|python| python.enable_pip_review_local)
.unwrap_or(false);
}

pub fn display_time(&self) -> bool {
self.config_file.display_time.unwrap_or(true)
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ For more information about this issue see https://askubuntu.com/questions/110969
runner.execute(Step::Mamba, "mamba", || generic::run_mamba_update(&ctx))?;
runner.execute(Step::Pip3, "pip3", || generic::run_pip3_update(run_type))?;
runner.execute(Step::PipReview, "pip-review", || generic::run_pip_review_update(&ctx))?;
runner.execute(Step::PipReviewLocal, "pip-review (local)", || {
generic::run_pip_review_local_update(&ctx)
})?;
runner.execute(Step::Pipupgrade, "pipupgrade", || generic::run_pipupgrade_update(&ctx))?;
runner.execute(Step::Ghcup, "ghcup", || generic::run_ghcup_update(run_type))?;
runner.execute(Step::Stack, "stack", || generic::run_stack_update(run_type))?;
Expand Down
19 changes: 19 additions & 0 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,25 @@ pub fn run_pip_review_update(ctx: &ExecutionContext) -> Result<()> {

Ok(())
}
pub fn run_pip_review_local_update(ctx: &ExecutionContext) -> Result<()> {
let pip_review = require("pip-review")?;

print_separator("pip-review (local)");

if !ctx.config().enable_pip_review_local() {
print_warning(
"Pip-review (local) is disabled by default. Enable it by setting enable_pip_review_local=true in the configuration.",
);
return Err(SkipStep(String::from("Pip-review (local) is disabled by default")).into());
}
ctx.run_type()
.execute(pip_review)
.arg("--local")
.arg("--auto")
.status_checked_with_codes(&[1])?;

Ok(())
}
pub fn run_pipupgrade_update(ctx: &ExecutionContext) -> Result<()> {
let pipupgrade = require("pipupgrade")?;

Expand Down

0 comments on commit 54301a6

Please sign in to comment.