Skip to content

Commit 91aaf46

Browse files
committed
Allow to specify custom version during build
1 parent a3996a0 commit 91aaf46

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

crates/pixi_consts/src/consts.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ pub const PYPROJECT_MANIFEST: &str = "pyproject.toml";
1212
pub const PROJECT_LOCK_FILE: &str = "pixi.lock";
1313
pub const CONFIG_FILE: &str = "config.toml";
1414
pub const PIXI_DIR: &str = ".pixi";
15-
pub const PIXI_VERSION: &str = "0.33.0";
15+
pub const PIXI_VERSION: &str = match option_env!("PIXI_VERSION") {
16+
Some(v) => v,
17+
None => "0.33.0",
18+
};
1619
pub const PREFIX_FILE_NAME: &str = "pixi_env_prefix";
1720
pub const ENVIRONMENTS_DIR: &str = "envs";
1821
pub const SOLVE_GROUP_ENVIRONMENTS_DIR: &str = "solve-group-envs";

docs/packaging.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ the user to the package manager they should be using to update pixi.
4242
PIXI_SELF_UPDATE_DISABLED_MESSAGE="`self-update` has been disabled for this build. Run `brew upgrade pixi` instead" cargo build --locked --profile dist
4343
```
4444

45+
#### Custom version
46+
47+
You can specify a custom version string to be used in the `--version` output by setting the `PIXI_VERSION` environment variable during the build.
48+
49+
```shell
50+
PIXI_VERSION="HEAD-123456" cargo build --locked --profile dist
51+
```
52+
4553
## Shell completion
4654

4755
After building pixi you can generate shell autocompletion scripts by running

src/cli/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clap::Parser;
44
use clap_verbosity_flag::Verbosity;
55
use indicatif::ProgressDrawTarget;
66
use miette::IntoDiagnostic;
7+
use pixi_consts::consts;
78
use tracing_subscriber::{
89
filter::LevelFilter, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt,
910
EnvFilter,
@@ -39,9 +40,9 @@ pub mod upload;
3940

4041
#[derive(Parser, Debug)]
4142
#[command(
42-
version,
43-
about = "
44-
Pixi [version 0.33.0] - Developer Workflow and Environment Management for Multi-Platform, Language-Agnostic Projects.
43+
version(consts::PIXI_VERSION),
44+
about = format!("
45+
Pixi [version {}] - Developer Workflow and Environment Management for Multi-Platform, Language-Agnostic Projects.
4546
4647
Pixi is a versatile developer workflow tool designed to streamline the management of your project's dependencies, tasks, and environments.
4748
Built on top of the Conda ecosystem, Pixi offers seamless integration with the PyPI ecosystem.
@@ -62,7 +63,7 @@ Need Help?
6263
Ask a question on the Prefix Discord server: https://discord.gg/kKV8ZxyzY4
6364
6465
For more information, see the documentation at: https://pixi.sh
65-
"
66+
", consts::PIXI_VERSION)
6667
)]
6768
#[clap(arg_required_else_help = true)]
6869
struct Args {

tbump.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,12 @@ src = "install/install.sh"
6363
search = "Version: v{current_version}"
6464
src = "install/install.ps1"
6565

66-
[[file]]
67-
search = "version {current_version}"
68-
src = "src/cli/mod.rs"
69-
7066
[[file]]
7167
search = "PIXI_VERSION = \"{current_version}\""
7268
src = "tests/integration/common.py"
7369

7470
[[file]]
75-
search = "pub const PIXI_VERSION: &str = \"{current_version}\";"
71+
search = "None => \"{current_version}\","
7672
src = "crates/pixi_consts/src/consts.rs"
7773

7874
[[field]]

0 commit comments

Comments
 (0)