1# Define custom utilities 2# Test for OSX with [ -n "$IS_OSX" ] 3 4function remove_travis_ve_pip { 5 # Removing the system virtualenv or pip can be very problematic for 6 # macOS on Kokoro, so just leave them be. 7 :; 8} 9 10function install_pip { 11 check_python 12 PIP_CMD="sudo $PYTHON_EXE -m pip${pip_args:+ $pip_args}" 13 $PIP_CMD install --upgrade pip 14} 15 16function install_virtualenv { 17 check_python 18 check_pip 19 $PIP_CMD install --upgrade virtualenv 20 VIRTUALENV_CMD="$PYTHON_EXE -m virtualenv" 21} 22 23function pre_build { 24 # Any stuff that you need to do before you start building the wheels 25 # Runs in the root directory of this repository. 26 pushd protobuf 27 28 # Build protoc and protobuf libraries 29 bazel build //:protoc 30 export PROTOC=$PWD/bazel-bin/protoc 31 mkdir src/.libs 32 ln -s $PWD/bazel-bin/libprotobuf.a src/.libs/libprotobuf.a 33 ln -s $PWD/bazel-bin/libprotobuf_lite.a src/.libs/libprotobuf-lite.a 34 35 # Generate python dependencies. 36 pushd python 37 python setup.py build_py 38 popd 39 40 popd 41} 42 43function bdist_wheel_cmd { 44 # Builds wheel with bdist_wheel, puts into wheelhouse 45 # 46 # It may sometimes be useful to use bdist_wheel for the wheel building 47 # process. For example, versioneer has problems with versions which are 48 # fixed with bdist_wheel: 49 # https://github.com/warner/python-versioneer/issues/121 50 local abs_wheelhouse=$1 51 52 # Modify build version 53 pwd 54 ls 55 python setup.py bdist_wheel --cpp_implementation --compile_static_extension 56 cp dist/*.whl $abs_wheelhouse 57} 58 59function build_wheel { 60 build_wheel_cmd "bdist_wheel_cmd" $@ 61} 62 63function run_tests { 64 # Runs tests on installed distribution from an empty directory 65 python --version 66 python -c "from google.protobuf.pyext import _message;" 67} 68