From f7151e3ae052f65564584acfbd32df6e2be1a1af Mon Sep 17 00:00:00 2001 From: Wenbing Li <10278425+wenbingl@users.noreply.github.com> Date: Wed, 24 Aug 2022 14:39:33 -0700 Subject: [PATCH] support build_id on Python package building (#281) * support buildid in package building * undo the change on build.sh * build.sh issue on macos --- build.sh | 9 ++++++--- setup.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index 1fc2b655..6adaae18 100755 --- a/build.sh +++ b/build.sh @@ -4,13 +4,16 @@ set -e -x -u OSNAME=$(uname -s) -if [[ "$OSNAME" == "Darwin" ]]; then - alias nproc="sysctl -n hw.logicalcpu" +if [ -z ${CPU_NUMBER+x} ]; then + if [[ "$OSNAME" == "Darwin" ]]; then + CPU_NUMBER=$(sysctl -n hw.logicalcpu) + else + CPU_NUMBER=$(nproc) + fi fi BUILD_FLAVOR=RelWithDebInfo target_dir=out/$OSNAME/$BUILD_FLAVOR mkdir -p "$target_dir" && cd "$target_dir" -if [ -z ${CPU_NUMBER+x} ]; then CPU_NUMBER=$(nproc); fi # it looks the parallel build on CI pipeline machine causes crashes. cmake "$@" ../../.. && cmake --build . --config $BUILD_FLAVOR --parallel "${CPU_NUMBER}" diff --git a/setup.py b/setup.py index 32b9d927..1fe3841c 100644 --- a/setup.py +++ b/setup.py @@ -126,10 +126,14 @@ def read_version(): version_str = line[0].split('=')[1].strip('" \n\r') # is it a dev build or release? - if os.path.isdir(os.path.join(TOP_DIR, '.git')): - rel_br, cid = read_git_refs() - if not rel_br: - version_str += '+' + cid[:7] + build_id = os.getenv('BUILD_BUILDID', None) + if build_id is not None: + version_str += '.{}'.format(build_id) + else: + if os.path.isdir(os.path.join(TOP_DIR, '.git')): + rel_br, cid = read_git_refs() + if not rel_br: + version_str += '+' + cid[:7] return version_str