1
0

osx 927 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. set -ex
  3. python_version() {
  4. python -V 2>&1
  5. }
  6. python3_version() {
  7. python3 -V 2>&1
  8. }
  9. openssl_version() {
  10. python -c "import ssl; print ssl.OPENSSL_VERSION"
  11. }
  12. desired_python3_version="3.6.4"
  13. desired_python3_brew_version="3.6.4_2"
  14. python3_formula="https://raw.githubusercontent.com/Homebrew/homebrew-core/b4e69a9a592232fa5a82741f6acecffc2f1d198d/Formula/python3.rb"
  15. PATH="/usr/local/bin:$PATH"
  16. if !(which brew); then
  17. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  18. fi
  19. brew update > /dev/null
  20. if !(python3_version | grep "$desired_python3_version"); then
  21. if brew list | grep python3; then
  22. brew unlink python3
  23. fi
  24. brew install "$python3_formula"
  25. brew switch python3 "$desired_python3_brew_version"
  26. fi
  27. echo "*** Using $(python3_version) ; $(python_version)"
  28. echo "*** Using $(openssl_version)"
  29. if !(which virtualenv); then
  30. pip install virtualenv
  31. fi