Skip to content

Commit 4c2d9e1

Browse files
authored
Use EnvVars in linehaul (#15931)
1 parent e23da5b commit 4c2d9e1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

crates/uv-client/src/linehaul.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use tracing::instrument;
55

66
use uv_pep508::MarkerEnvironment;
77
use uv_platform_tags::{Os, Platform};
8+
use uv_static::EnvVars;
89
use uv_version::version;
910

1011
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
@@ -64,9 +65,14 @@ impl LineHaul {
6465
#[instrument(name = "linehaul", skip_all)]
6566
pub fn new(markers: &MarkerEnvironment, platform: Option<&Platform>) -> Self {
6667
// https://github.com/pypa/pip/blob/24.0/src/pip/_internal/network/session.py#L87
67-
let looks_like_ci = ["BUILD_BUILDID", "BUILD_ID", "CI", "PIP_IS_CI"]
68-
.iter()
69-
.find_map(|&var_name| env::var(var_name).ok().map(|_| true));
68+
let looks_like_ci = [
69+
EnvVars::BUILD_BUILDID,
70+
EnvVars::BUILD_ID,
71+
EnvVars::CI,
72+
EnvVars::PIP_IS_CI,
73+
]
74+
.iter()
75+
.find_map(|&var_name| env::var(var_name).ok().map(|_| true));
7076

7177
let libc = match platform.map(Platform::os) {
7278
Some(Os::Manylinux { major, minor }) => Some(Libc {

crates/uv-static/src/env_vars.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,18 @@ impl EnvVars {
662662
#[attr_hidden]
663663
pub const CI: &'static str = "CI";
664664

665+
/// Azure DevOps build identifier, used to detect CI environments.
666+
#[attr_hidden]
667+
pub const BUILD_BUILDID: &'static str = "BUILD_BUILDID";
668+
669+
/// Generic build identifier, used to detect CI environments.
670+
#[attr_hidden]
671+
pub const BUILD_ID: &'static str = "BUILD_ID";
672+
673+
/// Pip environment variable to indicate CI environment.
674+
#[attr_hidden]
675+
pub const PIP_IS_CI: &'static str = "PIP_IS_CI";
676+
665677
/// Use to set the .netrc file location.
666678
pub const NETRC: &'static str = "NETRC";
667679

0 commit comments

Comments
 (0)