From 91aaf4662d321e8a83d5509779536183cf564a9b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 19 Oct 2024 22:33:18 +0200 Subject: [PATCH] Allow to specify custom version during build --- crates/pixi_consts/src/consts.rs | 5 ++++- docs/packaging.md | 8 ++++++++ src/cli/mod.rs | 9 +++++---- tbump.toml | 6 +----- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/crates/pixi_consts/src/consts.rs b/crates/pixi_consts/src/consts.rs index 227bc5062..69fe48889 100644 --- a/crates/pixi_consts/src/consts.rs +++ b/crates/pixi_consts/src/consts.rs @@ -12,7 +12,10 @@ pub const PYPROJECT_MANIFEST: &str = "pyproject.toml"; pub const PROJECT_LOCK_FILE: &str = "pixi.lock"; pub const CONFIG_FILE: &str = "config.toml"; pub const PIXI_DIR: &str = ".pixi"; -pub const PIXI_VERSION: &str = "0.33.0"; +pub const PIXI_VERSION: &str = match option_env!("PIXI_VERSION") { + Some(v) => v, + None => "0.33.0", +}; pub const PREFIX_FILE_NAME: &str = "pixi_env_prefix"; pub const ENVIRONMENTS_DIR: &str = "envs"; pub const SOLVE_GROUP_ENVIRONMENTS_DIR: &str = "solve-group-envs"; diff --git a/docs/packaging.md b/docs/packaging.md index 570404a6f..7a75a314f 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -42,6 +42,14 @@ the user to the package manager they should be using to update pixi. PIXI_SELF_UPDATE_DISABLED_MESSAGE="`self-update` has been disabled for this build. Run `brew upgrade pixi` instead" cargo build --locked --profile dist ``` +#### Custom version + +You can specify a custom version string to be used in the `--version` output by setting the `PIXI_VERSION` environment variable during the build. + +```shell +PIXI_VERSION="HEAD-123456" cargo build --locked --profile dist +``` + ## Shell completion After building pixi you can generate shell autocompletion scripts by running diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 1cf92eb86..6167b1ab0 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -4,6 +4,7 @@ use clap::Parser; use clap_verbosity_flag::Verbosity; use indicatif::ProgressDrawTarget; use miette::IntoDiagnostic; +use pixi_consts::consts; use tracing_subscriber::{ filter::LevelFilter, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, EnvFilter, @@ -39,9 +40,9 @@ pub mod upload; #[derive(Parser, Debug)] #[command( - version, - about = " -Pixi [version 0.33.0] - Developer Workflow and Environment Management for Multi-Platform, Language-Agnostic Projects. + version(consts::PIXI_VERSION), + about = format!(" +Pixi [version {}] - Developer Workflow and Environment Management for Multi-Platform, Language-Agnostic Projects. Pixi is a versatile developer workflow tool designed to streamline the management of your project's dependencies, tasks, and environments. Built on top of the Conda ecosystem, Pixi offers seamless integration with the PyPI ecosystem. @@ -62,7 +63,7 @@ Need Help? Ask a question on the Prefix Discord server: https://discord.gg/kKV8ZxyzY4 For more information, see the documentation at: https://pixi.sh -" +", consts::PIXI_VERSION) )] #[clap(arg_required_else_help = true)] struct Args { diff --git a/tbump.toml b/tbump.toml index 7208f0f56..d56b5e7f2 100644 --- a/tbump.toml +++ b/tbump.toml @@ -63,16 +63,12 @@ src = "install/install.sh" search = "Version: v{current_version}" src = "install/install.ps1" -[[file]] -search = "version {current_version}" -src = "src/cli/mod.rs" - [[file]] search = "PIXI_VERSION = \"{current_version}\"" src = "tests/integration/common.py" [[file]] -search = "pub const PIXI_VERSION: &str = \"{current_version}\";" +search = "None => \"{current_version}\"," src = "crates/pixi_consts/src/consts.rs" [[field]]