Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glean-build: Allow overwrite of Python venv using GLEAN_PYTHON_VENV_DIR #2996

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions glean-core/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! You can then access your metrics and pings directly by name within the `metrics` module.
//!
//! [`glean-parser`]: https://github.com/mozilla/glean_parser/
use std::env;
use std::{env, path::PathBuf};

use xshell_venv::{Result, Shell, VirtualEnv};

Expand Down Expand Up @@ -107,12 +107,19 @@ impl Builder {
}

let sh = Shell::new()?;
let venv = VirtualEnv::new(&sh, "py3-glean_parser")?;

let glean_parser = format!("glean_parser~={GLEAN_PARSER_VERSION}");
// TODO: Remove after we switched glean_parser away from legacy setup.py
venv.pip_install("setuptools")?;
venv.pip_install(&glean_parser)?;
let venv = if let Ok(env_dir) = env::var("GLEAN_PYTHON_VENV_DIR") {
eprintln!("got env dir: {env_dir}");
let env_path = PathBuf::from(env_dir);
VirtualEnv::with_path(&sh, &env_path)?
} else {
let venv = VirtualEnv::new(&sh, "py3-glean_parser")?;

let glean_parser = format!("glean_parser~={GLEAN_PARSER_VERSION}");
// TODO: Remove after we switched glean_parser away from legacy setup.py
venv.pip_install("setuptools")?;
venv.pip_install(&glean_parser)?;
venv
};

for file in &self.files {
println!("cargo:rerun-if-changed={file}");
Expand Down
Loading