-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathentrypoint.sh
More file actions
72 lines (59 loc) · 2.64 KB
/
entrypoint.sh
File metadata and controls
72 lines (59 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# 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.
set -e -x
# CLI arguments
PY_VERSION=$1
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
# Map Python version to manylinux path
declare -A python_map=( ["3.10"]="cp310-cp310" ["3.11"]="cp311-cp311" ["3.12"]="cp312-cp312" ["3.13"]="cp313-cp313" ["3.14"]="cp314-cp314")
PY_VER=${python_map[$PY_VERSION]}
PIP_INSTALL_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir -q"
PYTHON_COMMAND="/opt/python/${PY_VER}/bin/python"
# Update pip and install build tools
$PIP_INSTALL_COMMAND --upgrade pip
$PIP_INSTALL_COMMAND cmake setuptools wheel build pybind11
# Install system protobuf (CONFIG mode compatible)
yum install -y protobuf-devel protobuf-compiler glog-devel 2>/dev/null || {
# Fallback: build protobuf from source if yum packages unavailable
original_dir=$(pwd)
git clone --depth 1 --branch v28.3 https://github.com/protocolbuffers/protobuf.git /tmp/protobuf
cd /tmp/protobuf
git submodule update --init --recursive
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local \
-Dprotobuf_BUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-Dprotobuf_BUILD_TESTS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_ABSL_PROVIDER=module
cmake --build . --target install -j$(nproc)
cd $original_dir
}
export PIP_EXTRA_INDEX_URL="https://www.paddlepaddle.org.cn/packages/nightly/cpu/"
# Build Paddle2ONNX wheels
$PYTHON_COMMAND -m build --wheel || { echo "Building wheels failed."; exit 1; }
# Bundle external shared libraries into the wheels
failed_wheels=$PWD/failed-wheels
rm -f "$failed_wheels"
find . -type f -iname "*-linux*.whl" -exec sh -c "auditwheel repair '{}' -w \$(dirname '{}') --exclude libpaddle.so || { echo 'Repairing wheels failed.'; auditwheel show '{}' >> '$failed_wheels'; }" \;
if [[ -f "$failed_wheels" ]]; then
echo "Repairing wheels failed:"
cat failed-wheels
exit 1
fi
# Remove useless *-linux*.whl; only keep manylinux*.whl
rm -f dist/*-linux*.whl
echo "Successfully built wheels:"
find . -type f -iname "*manylinux*.whl"