Эх сурвалжийг харах

Python wheel kokoro dev (#5002)

* Add config for building python wheel

* Update submodules

* Fix setup.py to use c++11

* Fix syntax error

* Fix syntax error

* Add dir for artifact

* Update artifact dirctory

* Remove python 3.3

* Clean up virtual env

* Clean up env

* Test environment

* Test env variable

* Automatic update version number

* Remove dependency on python-wheel branch
Paul Yang 7 жил өмнө
parent
commit
fba5ef410a

+ 45 - 0
kokoro/release/python/linux/build_artifacts.sh

@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -ex
+
+# change to repo root
+pushd $(dirname $0)/../../../..
+
+export REPO_DIR=protobuf
+export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
+export BUILD_COMMIT=v$BUILD_VERSION
+export PLAT=x86_64
+export UNICODE_WIDTH=32
+export MACOSX_DEPLOYMENT_TARGET=10.9
+
+mkdir artifacts
+export ARTIFACT_DIR=$(pwd)/artifacts
+
+git clone https://github.com/matthew-brett/multibuild.git
+cp kokoro/release/python/linux/config.sh config.sh
+
+build_artifact_version() {
+  MB_PYTHON_VERSION=$1
+
+  # Clean up env
+  rm -rf venv
+  sudo rm -rf protobuf
+  git clone https://github.com/google/protobuf.git
+
+  source multibuild/common_utils.sh
+  source multibuild/travis_steps.sh
+  before_install
+
+  clean_code $REPO_DIR $BUILD_COMMIT
+  sed -i '/Wno-sign-compare/a \ \ \ \ \ \ \ \ extra_compile_args.append("-std=c++11")' $REPO_DIR/python/setup.py
+  cat $REPO_DIR/python/setup.py
+
+  build_wheel $REPO_DIR/python $PLAT
+
+  mv wheelhouse/* $ARTIFACT_DIR
+}
+
+build_artifact_version 2.7
+build_artifact_version 3.4
+build_artifact_version 3.5
+build_artifact_version 3.6

+ 48 - 0
kokoro/release/python/linux/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="-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;"
+}

+ 8 - 0
kokoro/release/python/linux/release.cfg

@@ -0,0 +1,8 @@
+# Configuration for Linux release builds
+build_file: "protobuf/kokoro/release/python/linux/build_artifacts.sh"
+
+action {
+  define_artifacts {
+    regex: "github/protobuf/artifacts/**"
+  }
+}