config.sh 1.6 KB

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