Skip to content

Commit

Permalink
Allow to specify custom version during build
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Oct 20, 2024
1 parent a3996a0 commit 91aaf46
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
5 changes: 4 additions & 1 deletion crates/pixi_consts/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 8 additions & 0 deletions docs/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
6 changes: 1 addition & 5 deletions tbump.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down

0 comments on commit 91aaf46

Please sign in to comment.