Browse Source

Fix python release build. (#5636)

* Fix python release build.
* Separate config.sh by platform
* Use KOKORO_JOR_NAME to determine the BUILD_COMMIT.
* Use -std=c++14 on MacOS so -latomic can be used.
Hao Nguyen 6 years ago
parent
commit
532c42586f

+ 7 - 1
kokoro/release/python/linux/build_artifacts.sh

@@ -7,11 +7,17 @@ pushd $(dirname $0)/../../../..
 
 
 export REPO_DIR=protobuf
 export REPO_DIR=protobuf
 export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
 export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
-export BUILD_COMMIT=v$BUILD_VERSION
+if [ -z $KOKORO_JOB_NAME ]; then
+  export BUILD_COMMIT=master
+else
+  export BUILD_COMMIT=`echo "$KOKORO_JOB_NAME" | cut -d '/' -f 3`
+fi
 export PLAT=x86_64
 export PLAT=x86_64
 export UNICODE_WIDTH=32
 export UNICODE_WIDTH=32
 export MACOSX_DEPLOYMENT_TARGET=10.9
 export MACOSX_DEPLOYMENT_TARGET=10.9
 
 
+rm -rf artifacts/
+rm -rf multibuild/
 mkdir artifacts
 mkdir artifacts
 export ARTIFACT_DIR=$(pwd)/artifacts
 export ARTIFACT_DIR=$(pwd)/artifacts
 
 

+ 2 - 0
kokoro/release/python/linux/config.sh

@@ -6,6 +6,8 @@ function pre_build {
     # Runs in the root directory of this repository.
     # Runs in the root directory of this repository.
     pushd protobuf
     pushd protobuf
 
 
+    yum install -y devtoolset-2-libatomic-devel
+
     # Build protoc
     # Build protoc
     ./autogen.sh
     ./autogen.sh
     ./configure
     ./configure

+ 8 - 2
kokoro/release/python/macos/build_artifacts.sh

@@ -7,17 +7,23 @@ pushd $(dirname $0)/../../../..
 
 
 export REPO_DIR=protobuf
 export REPO_DIR=protobuf
 export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
 export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
-export BUILD_COMMIT=v$BUILD_VERSION
+if [ -z $KOKORO_JOB_NAME ]; then
+  export BUILD_COMMIT=master
+else
+  export BUILD_COMMIT=`echo "$KOKORO_JOB_NAME" | cut -d '/' -f 3`
+fi
 export PLAT=x86_64
 export PLAT=x86_64
 export UNICODE_WIDTH=32
 export UNICODE_WIDTH=32
 export MACOSX_DEPLOYMENT_TARGET=10.9
 export MACOSX_DEPLOYMENT_TARGET=10.9
 export TRAVIS_OS_NAME="osx"
 export TRAVIS_OS_NAME="osx"
 
 
+rm -rf artifacts/
+rm -rf multibuild/
 mkdir artifacts
 mkdir artifacts
 export ARTIFACT_DIR=$(pwd)/artifacts
 export ARTIFACT_DIR=$(pwd)/artifacts
 
 
 git clone https://github.com/matthew-brett/multibuild.git
 git clone https://github.com/matthew-brett/multibuild.git
-cp kokoro/release/python/linux/config.sh config.sh
+cp kokoro/release/python/macos/config.sh config.sh
 
 
 OLD_PATH=$PATH
 OLD_PATH=$PATH
 
 

+ 48 - 0
kokoro/release/python/macos/config.sh

@@ -0,0 +1,48 @@
+# Define custom utilities
+# Test for OSX with [ -n "$IS_OSX" ]
+
+function pre_build {
+    # Any stuff that you need to do before you start building the wheels
+    # Runs in the root directory of this repository.
+    pushd protobuf
+
+    # Build protoc
+    ./autogen.sh
+    ./configure
+
+    CXXFLAGS="-std=c++14 -fPIC -g -O2" ./configure
+    make -j8
+
+    # Generate python dependencies.
+    pushd python
+    python setup.py build_py
+    popd
+
+    popd
+}
+
+function bdist_wheel_cmd {
+    # Builds wheel with bdist_wheel, puts into wheelhouse
+    #
+    # It may sometimes be useful to use bdist_wheel for the wheel building
+    # process.  For example, versioneer has problems with versions which are
+    # fixed with bdist_wheel:
+    # https://github.com/warner/python-versioneer/issues/121
+    local abs_wheelhouse=$1
+
+    # Modify build version
+    pwd
+    ls
+    python setup.py bdist_wheel --cpp_implementation --compile_static_extension
+    cp dist/*.whl $abs_wheelhouse
+}
+
+function build_wheel {
+    build_wheel_cmd "bdist_wheel_cmd" $@
+}
+
+function run_tests {
+    # Runs tests on installed distribution from an empty directory
+    python --version
+    python -c "from google.protobuf.pyext import _message;"
+}