mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-10 03:44:54 +00:00
Burn cargo version within binary.
This commit is contained in:
parent
15756ba1d4
commit
982a04246b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
target
|
target
|
||||||
router/tokenizer.json
|
router/tokenizer.json
|
||||||
|
launcher/src/versions.rs
|
||||||
|
@ -2,13 +2,23 @@ use std::fs::File;
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
pub fn cargo_version() -> Option<String> {
|
||||||
|
let output = Command::new("cargo").args(&["version"]).output().ok()?;
|
||||||
|
let output = String::from_utf8(output.stdout).ok()?;
|
||||||
|
Some(output.trim().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
.args(&["rev-parse", "HEAD"])
|
.args(&["rev-parse", "HEAD"])
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let git_hash = String::from_utf8(output.stdout).unwrap().trim().to_string();
|
let git_hash = String::from_utf8(output.stdout).unwrap().trim().to_string();
|
||||||
|
|
||||||
|
let cargo_version = cargo_version().unwrap_or("N/A".to_string());
|
||||||
let mut file = File::create("src/versions.rs").unwrap();
|
let mut file = File::create("src/versions.rs").unwrap();
|
||||||
file.write(format!(r#"pub static GIT_HASH: &str = "{git_hash}";"#).as_bytes())
|
file.write(format!("pub static GIT_HASH: &str = \"{git_hash}\";\n").as_bytes())
|
||||||
|
.unwrap();
|
||||||
|
file.write(format!(r#"pub static CARGO_VERSION: &str = "{cargo_version}";"#).as_bytes())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,6 @@ pub fn nvidia_smi() -> Option<String> {
|
|||||||
Some(output.trim().to_string())
|
Some(output.trim().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cargo_version() -> Option<String> {
|
|
||||||
let output = Command::new("cargo").args(&["version"]).output().ok()?;
|
|
||||||
let output = String::from_utf8(output.stdout).ok()?;
|
|
||||||
Some(output.trim().to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn docker_image() -> Option<String> {
|
pub fn docker_image() -> Option<String> {
|
||||||
let output = Command::new("docker")
|
let output = Command::new("docker")
|
||||||
.args(&[
|
.args(&[
|
||||||
@ -29,10 +23,7 @@ pub fn docker_image() -> Option<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_env() {
|
pub fn print_env() {
|
||||||
println!(
|
println!("Cargo version: {}", crate::versions::CARGO_VERSION);
|
||||||
"Cargo version: {}",
|
|
||||||
cargo_version().unwrap_or("N/A".to_string())
|
|
||||||
);
|
|
||||||
println!("Commit SHA: {}", crate::versions::GIT_HASH);
|
println!("Commit SHA: {}", crate::versions::GIT_HASH);
|
||||||
println!(
|
println!(
|
||||||
"Docker image sha: {}",
|
"Docker image sha: {}",
|
||||||
|
@ -1 +0,0 @@
|
|||||||
pub static GIT_HASH: &str = "61fd8c3c014d9ea31bc1df736fd276606ce29d66";
|
|
Loading…
Reference in New Issue
Block a user