This is an automated email from the ASF dual-hosted git repository.

aloyszhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 252bf59d2d [INLONG-10736][SDK] Python sdk build script support for 
skipping c++ sdk build step (#10737)
252bf59d2d is described below

commit 252bf59d2da7a6c99c7a8b2008d7b7f4f07cd221
Author: LeeWY <61183968+yfsn...@users.noreply.github.com>
AuthorDate: Wed Jul 31 11:35:09 2024 +0800

    [INLONG-10736][SDK] Python sdk build script support for skipping c++ sdk 
build step (#10737)
---
 .../dataproxy-sdk-python/build.sh                  | 56 +++++++++++++---------
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/build.sh 
b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/build.sh
index 388edcbc61..946ac6f724 100755
--- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/build.sh
+++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/build.sh
@@ -18,7 +18,20 @@
 
 #!/bin/bash
 
-BASE_DIR=$(pwd)
+BASE_DIR=`dirname "$0"`
+PY_SDK_DIR=`cd "$BASE_DIR";pwd`
+
+echo "The python sdk directory is: $PY_SDK_DIR"
+
+# Check if dataproxy-sdk-cpp directory exists in the parent directory
+if [ ! -d "$PY_SDK_DIR/../dataproxy-sdk-cpp" ]; then
+    echo "Error: cannot find the dataproxy-cpp-sdk directory! The 
dataproxy-cpp-sdk directory must be located in the same directory as the 
dataproxy-python-sdk directory."
+    exit 1
+fi
+
+CPP_SDK_DIR=`cd "$PY_SDK_DIR/../dataproxy-sdk-cpp";pwd`
+
+echo "The cpp sdk directory is: $CPP_SDK_DIR"
 
 # Check CMake version
 CMAKE_VERSION=$(cmake --version | head -n 1 | cut -d " " -f 3)
@@ -37,37 +50,36 @@ if [ "$(printf '%s\n' "$PYTHON_REQUIRED" "$PYTHON_VERSION" 
| sort -V | head -n1)
 fi
 
 # Clone and build pybind11
-git clone https://github.com/pybind/pybind11.git
-cd pybind11
-mkdir build && cd build
-cmake ..
-cmake --build . --config Release --target check
+git clone https://github.com/pybind/pybind11.git $PY_SDK_DIR/pybind11
+mkdir $PY_SDK_DIR/pybind11/build && cd $PY_SDK_DIR/pybind11/build
+cmake $PY_SDK_DIR/pybind11
+cmake --build $PY_SDK_DIR/pybind11/build --config Release --target check
 make check -j 4
-cd $BASE_DIR
 
-# Clone and build dataproxy-sdk-cpp
-git clone https://github.com/apache/inlong.git
-mv ./inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp ./
-rm -r ./inlong
-cd ./dataproxy-sdk-cpp
-chmod +x ./build.sh
-./build.sh
-cd $BASE_DIR
+# Build dataproxy-sdk-cpp(If the dataproxy-sdk-cpp has been compiled, this 
step will be skipped)
+if [ ! -e "$CPP_SDK_DIR/release/lib/dataproxy_sdk.a" ]; then
+    chmod +x $CPP_SDK_DIR/build.sh
+    cd $CPP_SDK_DIR
+    . $CPP_SDK_DIR/build.sh
+    cp -r $CPP_SDK_DIR $PY_SDK_DIR
+else
+    cp -r $CPP_SDK_DIR $PY_SDK_DIR
+    echo "Skipped build dataproxy-sdk-cpp"
+fi
 
 # Build Python SDK
-if [ -d "./build" ]; then
-    rm -r ./build
+if [ -d "$PY_SDK_DIR/build" ]; then
+    rm -r $PY_SDK_DIR/build
 fi
-mkdir build && cd build
-cmake ..
+mkdir $PY_SDK_DIR/build && cd $PY_SDK_DIR/build
+cmake $PY_SDK_DIR
 make
-cd $BASE_DIR
 
 # Get Python site-packages directory
 SITE_PACKAGES_DIR=$(python -c "import site; print(site.getsitepackages()[0])")
 
 # Copy generated .so file to site-packages directory
-find ./build -name "*.so" -print0 | xargs -0 -I {} bash -c 'rm -f $0/$1; cp $1 
$0' $SITE_PACKAGES_DIR {}
+find $PY_SDK_DIR/build -name "*.so" -print0 | xargs -0 -I {} bash -c 'rm -f 
$0/$1; cp $1 $0' $SITE_PACKAGES_DIR {}
 
 # Clean
-rm -r ./pybind11 ./dataproxy-sdk-cpp
\ No newline at end of file
+rm -r $PY_SDK_DIR/pybind11 $PY_SDK_DIR/dataproxy-sdk-cpp
\ No newline at end of file

Reply via email to