Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions build2cmake/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl Build {

pub struct General {
pub name: String,

/// Hugging Face Hub license identifier.
pub license: Option<String>,

pub backends: Vec<Backend>,
pub hub: Option<Hub>,
pub python_depends: Option<Vec<String>>,
Expand Down
1 change: 1 addition & 0 deletions build2cmake/src/config/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl TryFrom<Build> for super::Build {
Ok(Self {
general: super::General {
name: build.general.name,
license: None,
backends,
hub: None,
python_depends: None,
Expand Down
1 change: 1 addition & 0 deletions build2cmake/src/config/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl General {

super::General {
name: general.name,
license: None,
backends,
cuda,
hub: general.hub.map(Into::into),
Expand Down
4 changes: 4 additions & 0 deletions build2cmake/src/config/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub struct Build {
pub struct General {
pub name: String,

pub license: Option<String>,

pub backends: Vec<Backend>,

pub cuda: Option<CudaGeneral>,
Expand Down Expand Up @@ -141,6 +143,7 @@ impl From<General> for super::General {
fn from(general: General) -> Self {
Self {
name: general.name,
license: general.license,
backends: general.backends.into_iter().map(Into::into).collect(),
cuda: general.cuda.map(Into::into),
hub: general.hub.map(Into::into),
Expand Down Expand Up @@ -293,6 +296,7 @@ impl From<super::General> for General {
fn from(general: super::General) -> Self {
Self {
name: general.name,
license: general.license,
backends: general.backends.into_iter().map(Into::into).collect(),
cuda: general.cuda.map(Into::into),
hub: general.hub.map(Into::into),
Expand Down
12 changes: 3 additions & 9 deletions build2cmake/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct Metadata {
python_depends: Vec<String>,
}

impl Metadata {
pub fn new(python_depends: impl Into<Vec<String>>) -> Self {
Self {
python_depends: python_depends.into(),
}
}
#[serde(skip_serializing_if = "Option::is_none")]
pub license: Option<String>,
pub python_depends: Vec<String>,
}
5 changes: 4 additions & 1 deletion build2cmake/src/torch/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ pub fn write_metadata(backend: Backend, general: &General, file_set: &mut FileSe
.chain(general.backend_python_depends(backend))
.collect::<Result<Vec<_>>>()?;

let metadata = Metadata::new(python_depends);
let metadata = Metadata {
license: general.license.clone(),
python_depends,
};

serde_json::to_writer(writer, &metadata)?;

Expand Down
1 change: 1 addition & 0 deletions examples/silu-and-mul/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[general]
name = "silu-and-mul"
license = "apache-2.0"
backends = [
"cpu",
"cuda",
Expand Down
Loading