run_distrib_test.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. # Copyright 2015 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -ex
  16. cd "$(dirname "$0")"
  17. shopt -s nullglob
  18. # Pick up the source dist archive whatever its version is
  19. SDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-*.tar.gz)
  20. BDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-*.whl)
  21. TOOLS_SDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_tools-*.tar.gz)
  22. TOOLS_BDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_tools-*.whl)
  23. function make_virtualenv() {
  24. virtualenv "$1"
  25. "$1/bin/python" -m pip install --upgrade six pip
  26. "$1/bin/python" -m pip install cython
  27. }
  28. function at_least_one_installs() {
  29. for file in "$@"; do
  30. if python -m pip install "$file"; then
  31. return 0
  32. fi
  33. done
  34. return -1
  35. }
  36. make_virtualenv bdist_test
  37. make_virtualenv sdist_test
  38. #
  39. # Install our distributions in order of dependencies
  40. #
  41. (source bdist_test/bin/activate && at_least_one_installs "${BDIST_ARCHIVES[@]}")
  42. (source bdist_test/bin/activate && at_least_one_installs "${TOOLS_BDIST_ARCHIVES[@]}")
  43. (source sdist_test/bin/activate && at_least_one_installs "${SDIST_ARCHIVES[@]}")
  44. (source sdist_test/bin/activate && at_least_one_installs "${TOOLS_SDIST_ARCHIVES[@]}")
  45. #
  46. # Test our distributions
  47. #
  48. # TODO(jtattermusch): add a .proto file to the distribtest, generate python
  49. # code from it and then use the generated code from distribtest.py
  50. (source bdist_test/bin/activate && python -m grpc.tools.protoc --help)
  51. (source sdist_test/bin/activate && python -m grpc.tools.protoc --help)
  52. (source bdist_test/bin/activate && python distribtest.py)
  53. (source sdist_test/bin/activate && python distribtest.py)