Skip to content

Commit

Permalink
support cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
zheyang0825 committed Feb 22, 2024
1 parent 986ce7e commit 42ce7eb
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ build
dist
*.egg-info
.vscode
python/secretflowapis
python/secretflowapis
Cargo.lock
27 changes: 27 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "sdc_apis"
version = "0.2.1-dev20240222"
edition = "2021"
description = "SecretFlow Data Capsule apis proto generated Rust"
readme = "README.md"
repository = "https://github.com/zheyang0825/secure-data-capsule-apis.git"
license-file = "LICENSE"
include = ["secretflowapis", "lib.rs", "build.rs"]


[lib]
name = "sdc_apis"
path = "lib.rs"

[dependencies]
tonic = "0.9.2"
prost = "0.11"
prost-types = "0.11.1"
serde = { version = "1.0", features = ["derive"] }
prost-wkt = "0.4"
prost-wkt-types = "0.4"

[build-dependencies]
tonic-build = "0.9.2"
prost-wkt-build = "0.4"

27 changes: 27 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2023 Ant Group Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

fn main() -> Result<(), Box<dyn std::error::Error>> {
// compile protobuf
tonic_build::configure()
.type_attribute(".", "#[derive(serde::Deserialize, serde::Serialize)]")
.field_attribute("protected_header", "#[serde(rename=\"protected\")]")
.field_attribute(".secretflowapis.v2.sdc", "#[serde(default)]")
.extern_path(".google.protobuf.Any", "::prost_wkt_types::Any")
.compile(
&["secretflowapis/v2/sdc/capsule_manager/capsule_manager.proto"],
&["."], // specify the root location to search proto dependencies
)?;
Ok(())
}
25 changes: 25 additions & 0 deletions lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 Ant Group Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub mod secretflowapis {
pub mod v2 {
tonic::include_proto!("secretflowapis.v2");
pub mod sdc {
tonic::include_proto!("secretflowapis.v2.sdc");
pub mod capsule_manager {
tonic::include_proto!("secretflowapis.v2.sdc.capsule_manager");
}
}
}
}
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def read(fname):

setuptools.setup(
name="sdc-apis",
version="0.2.0.dev20230930",
version="0.2.1.dev20240222",
author="secretflow",
author_email="[email protected]",
description="SecretFlow Data Capsule apis proto generated python",
Expand Down

0 comments on commit 42ce7eb

Please sign in to comment.