Skip to content

Commit

Permalink
Install setuptools in Builder (#2671)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan-Erik Rediger <[email protected]>
  • Loading branch information
bendk and badboy authored Nov 21, 2023
1 parent b009bfa commit 91a55ec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions glean-core/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ rust-version = "1.63"

[dependencies]
xshell-venv = "1.1.0"

[dev-dependencies]
tempfile = "3.8.0"
32 changes: 32 additions & 0 deletions glean-core/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ impl Builder {
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)?;

for file in &self.files {
Expand All @@ -123,3 +125,33 @@ impl Builder {
Ok(())
}
}

#[cfg(test)]
mod test {
use std::{env, fs, path::PathBuf};

use super::*;

#[test]
fn test_builder() {
let package_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// clean out the previous venv, if it exists
let venv_dir = package_root.join("target").join("venv-py3-glean_parser");
if venv_dir.exists() {
fs::remove_dir_all(venv_dir).unwrap();
}
let metrics_yaml = package_root
.parent()
.unwrap()
.parent()
.unwrap()
.join("samples")
.join("rust")
.join("metrics.yaml");
let out_dir = tempfile::tempdir().unwrap();
Builder::with_output(out_dir.path().to_string_lossy())
.file(metrics_yaml.to_string_lossy())
.generate()
.expect("Error generating Glean bindings");
}
}

0 comments on commit 91a55ec

Please sign in to comment.