From f5f8809c1a48b1afe0134f24c0a9c5fe8fc599e5 Mon Sep 17 00:00:00 2001 From: chen zhiyu Date: Tue, 15 Dec 2020 22:04:07 +0800 Subject: [PATCH] 1. add python version selection 2.add dynamic flags setting. (#29612) --- paddle/scripts/musl_build/Dockerfile | 3 ++- paddle/scripts/musl_build/README.md | 9 +++++---- paddle/scripts/musl_build/build_docker.sh | 3 +++ paddle/scripts/musl_build/build_inside.sh | 4 +++- paddle/scripts/musl_build/build_paddle.sh | 12 +++++++++++- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/paddle/scripts/musl_build/Dockerfile b/paddle/scripts/musl_build/Dockerfile index 6621a90802..1c53284cef 100644 --- a/paddle/scripts/musl_build/Dockerfile +++ b/paddle/scripts/musl_build/Dockerfile @@ -11,8 +11,9 @@ # 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. +ARG PYTHON_VERSION=3.7 -FROM python:3.7-alpine3.11 +FROM python:${PYTHON_VERSION}-alpine3.11 USER root diff --git a/paddle/scripts/musl_build/README.md b/paddle/scripts/musl_build/README.md index d80e9d8b6f..9842971301 100644 --- a/paddle/scripts/musl_build/README.md +++ b/paddle/scripts/musl_build/README.md @@ -90,7 +90,7 @@ make -j8 compiling docker building script. it use alpine linux 3.10 as musl linux build enironment. it will try to install all the compiling tools, development packages, and python requirements for paddle musl compiling. environment variables: - + - PYTHON_VERSION: the version of python used for image building, default=3.7. - WITH_PRUNE_DAYS: prune old docker images, with days limitation. - WITH_REBUILD: force to rebuild the image, default=0. - WITH_REQUIREMENT: build with the python requirements, default=1. @@ -101,12 +101,13 @@ make -j8 - HTTPS_PROXY: use https proxy. 2. **build_paddle.sh** automatically or manually paddle building script. it will mount the root directory of paddle source to /paddle, and run compile procedure in /root/build directory. the output wheel package will save to the ./output directory relative to working directory. - - environment variables: + environment variables: - BUILD_MAN: build the paddle manually, default=0. - WITH_TEST: build with unitest, and run unitest check, default=0. - - WITH_PRUNE_CONTAINER: remove the container after building, default=0. + - WITH_PRUNE_CONTAINER: remove the container after building, default=1. + - CTEST_*: CTEST flages used for unit test. + - FLAGS_*: build flages used for paddle building. - HTTP_PROXY: use http proxy. - HTTPS_PROXY: use https proxy. diff --git a/paddle/scripts/musl_build/build_docker.sh b/paddle/scripts/musl_build/build_docker.sh index 8f6e5b07bb..0739cbdf73 100755 --- a/paddle/scripts/musl_build/build_docker.sh +++ b/paddle/scripts/musl_build/build_docker.sh @@ -24,6 +24,7 @@ source "$CUR_DIR/config.sh" WITH_REQUIREMENT="${WITH_REQUIREMENT-0}" WITH_UT_REQUIREMENT="${WITH_UT_REQUIREMENT-0}" WITH_REBUILD="${WITH_REBUILD-0}" +PYTHON_VERSION="${PYTHON_VERSION-3.7}" # exit when any command fails set -e @@ -43,6 +44,8 @@ function prune_image(){ function build_image(){ declare -a BUILD_ARGS + BUILD_ARGS+=("--build-arg" "PYTHON_VERSION=$PYTHON_VERSION") + echo ">>> python version: $PYTHON_VERSION" if [ "$HTTP_PROXY" ]; then BUILD_ARGS+=("--build-arg" "http_proxy=$HTTP_PROXY") diff --git a/paddle/scripts/musl_build/build_inside.sh b/paddle/scripts/musl_build/build_inside.sh index 32a6d5c3f3..04dea2086a 100755 --- a/paddle/scripts/musl_build/build_inside.sh +++ b/paddle/scripts/musl_build/build_inside.sh @@ -18,6 +18,8 @@ PADDLE_DIR=/paddle BUILD_DIR=$PWD/build echo ">>> paddle: $PADDLE_DIR" +export PADDLE_ROOT="$PADDLE_DIR" + echo ">>> python: $PYTHON_VERSION" # exit when any command fails @@ -64,7 +66,7 @@ fi echo ">>> compile source code" set -x -export FLAGS_call_stack_level=2 +export FLAGS_call_stack_level="${FLAGS_call_stack_level-2}" cmake "$PADDLE_DIR" \ -DWITH_MUSL=ON \ diff --git a/paddle/scripts/musl_build/build_paddle.sh b/paddle/scripts/musl_build/build_paddle.sh index 19d64d9150..879bb823c2 100755 --- a/paddle/scripts/musl_build/build_paddle.sh +++ b/paddle/scripts/musl_build/build_paddle.sh @@ -81,7 +81,17 @@ if [ "$BUILD_MAN" != "1" ]; then RUN_ARGS+=("--env" "WITH_UT_REQUIREMENT=$MOUNT_DIR/$UNITTEST_REQ") echo ">>> install unit test requirement" fi - + + for CTEST_FLAGS in $(env | grep ^CTEST_); do + RUN_ARGS+=("--env" "$CTEST_FLAGS") + echo ">>> ctest: $CTEST_FLAGS" + done + + for CBUILD_FLAGS in $(env | grep ^FLAGS_); do + RUN_ARGS+=("--env" "$CBUILD_FLAGS") + echo ">>> flags: $CBUILD_FLAGS" + done + if [ "$WITH_PRUNE_CONTAINER" == "1" ]; then echo ">>> with prune container" RUN_ARGS+=("--rm") -- GitLab