This is an automated email from the ASF dual-hosted git repository.
luchunliang 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 171eb76a1c [INLONG-10913][SDK] Optimize the python sdk build script
(#10917)
171eb76a1c is described below
commit 171eb76a1c5db7e17aaa7d24b9d1b5db9cb4c470
Author: yfsn666 <[email protected]>
AuthorDate: Tue Aug 27 16:04:07 2024 +0800
[INLONG-10913][SDK] Optimize the python sdk build script (#10917)
---
.../dataproxy-sdk-twins/dataproxy-sdk-python/build.sh | 16 ++++++++++++++++
.../dataproxy-sdk-python/requirements.txt | 1 +
2 files changed, 17 insertions(+)
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 f38f535dad..29759c6c9c 100755
--- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/build.sh
+++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/build.sh
@@ -51,6 +51,15 @@ if [ "$(printf '%s\n' "$PYTHON_REQUIRED" "$PYTHON_VERSION" |
sort -V | head -n1)
exit 1
fi
+# Install Python packages from requirements.txt
+if [ -f $PY_SDK_DIR/requirements.txt ]; then
+ echo "Installing Python packages from requirements.txt..."
+ pip install -r $PY_SDK_DIR/requirements.txt
+else
+ echo "Error: cannot find requirements.txt!"
+ exit 1
+fi
+
# Build pybind11(If the pybind11 has been compiled, this step will be skipped)
if [ ! -d "$PY_SDK_DIR/pybind11/build" ]; then
if [ -d "$PY_SDK_DIR/pybind11" ]; then
@@ -58,9 +67,16 @@ if [ ! -d "$PY_SDK_DIR/pybind11/build" ]; then
fi
git clone https://github.com/pybind/pybind11.git $PY_SDK_DIR/pybind11
mkdir $PY_SDK_DIR/pybind11/build && cd $PY_SDK_DIR/pybind11/build
+
+ # Add a trap command to delete the pybind11 folder if an error occurs
+ trap 'echo "Error occurred during pybind11 build. Deleting pybind11
folder..."; cd $PY_SDK_DIR; rm -r pybind11; exit 1' ERR
+
cmake $PY_SDK_DIR/pybind11
cmake --build $PY_SDK_DIR/pybind11/build --config Release --target check
make -j 4
+
+ # Remove the trap command if the build is successful
+ trap - ERR
else
echo "Skipped build pybind11"
fi
diff --git
a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/requirements.txt
b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/requirements.txt
new file mode 100644
index 0000000000..e160152b52
--- /dev/null
+++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/requirements.txt
@@ -0,0 +1 @@
+pytest>=7.1.2
\ No newline at end of file