From 71c52f21790636733400b9e478e88db69eabb294 Mon Sep 17 00:00:00 2001 From: zheyang0825 Date: Wed, 6 Mar 2024 10:48:27 +0800 Subject: [PATCH] feat: add cargo support --- .circleci/config.yml | 5 +++-- .gitignore | 3 ++- Cargo.toml | 27 +++++++++++++++++++++++++++ build.rs | 27 +++++++++++++++++++++++++++ lib.rs | 25 +++++++++++++++++++++++++ python/setup.py | 5 ++++- 6 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 lib.rs diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b587e3..e732f4b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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: @@ -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 diff --git a/.gitignore b/.gitignore index d5ef446..b0bdb25 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build dist *.egg-info .vscode -python/secretflowapis \ No newline at end of file +python/secretflowapis +Cargo.lock \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f44c6d5 --- /dev/null +++ b/Cargo.toml @@ -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" + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..35c1640 --- /dev/null +++ b/build.rs @@ -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> { + // 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(()) +} diff --git a/lib.rs b/lib.rs new file mode 100644 index 0000000..482da24 --- /dev/null +++ b/lib.rs @@ -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"); + } + } + } +} diff --git a/python/setup.py b/python/setup.py index 6b99773..a848b3b 100644 --- a/python/setup.py +++ b/python/setup.py @@ -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="secretflow-contact@service.alipay.com", description="SecretFlow Data Capsule apis proto generated python", @@ -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, )