Skip to content

Commit

Permalink
feat: add cargo support
Browse files Browse the repository at this point in the history
  • Loading branch information
zheyang0825 committed Mar 6, 2024
1 parent 47a9d68 commit 71c52f2
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: registry.hub.docker.com/secretflow/ubuntu-base-ci:0.4
- image: secretflow/trustedflow-dev-ubuntu22.04:latest
resource_class: large
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
Expand All @@ -50,7 +50,7 @@ jobs:
linux_publish:
docker:
- image: registry.hub.docker.com/secretflow/release-ci:0.7
- image: secretflow/trustedflow-dev-ubuntu22.04:latest
resource_class: large
parameters:
python_ver:
Expand All @@ -61,6 +61,7 @@ jobs:
- run:
name: "build package and publish"
command: |
source /root/miniconda3/etc/profile.d/conda.sh
conda create -n build python=<< parameters.python_ver >> -y
conda activate build
cd python
Expand Down
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");
}
}
}
}
5 changes: 4 additions & 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.dev20240305",
author="secretflow",
author_email="[email protected]",
description="SecretFlow Data Capsule apis proto generated python",
Expand All @@ -24,5 +24,8 @@ def read(fname):
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
options={
"bdist_wheel": {"plat_name": "manylinux2014_x86_64"},
},
include_package_data=True,
)

0 comments on commit 71c52f2

Please sign in to comment.