travis_install.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. set -ev
  3. # RVM overrides the cd, popd, and pushd shell commands, causing the
  4. # "shell_session_update: command not found" error on macOS when executing those
  5. # commands.
  6. unset -f cd popd pushd
  7. ################
  8. # Compiler setup
  9. ################
  10. # We can't use sudo, so we have to approximate the behaviour of setting the
  11. # default system compiler.
  12. mkdir -p ${HOME}/bin
  13. ln -s /usr/bin/g++-4.8 ${HOME}/bin/c++
  14. ln -s /usr/bin/gcc-4.8 ${HOME}/bin/cc
  15. export PATH=${HOME}/bin:${PATH}
  16. ##############
  17. # Python setup
  18. ##############
  19. PYENV_ROOT="${HOME}/.pyenv"
  20. if [ ! -d "${PYENV_ROOT}/.git" ]; then
  21. rm -rf ${PYENV_ROOT}
  22. git clone https://github.com/yyuu/pyenv.git ${PYENV_ROOT}
  23. fi
  24. pushd ${PYENV_ROOT}
  25. git fetch --tags
  26. git checkout v1.2.1
  27. popd
  28. export PATH="${PYENV_ROOT}/bin:${PATH}"
  29. eval "$(pyenv init -)"
  30. if [ "${YCM_PYTHON_VERSION}" == "2.7" ]; then
  31. # Tests are failing on Python 2.7.0 with the exception
  32. # "TypeError: argument can't be <type 'unicode'>"
  33. PYENV_VERSION="2.7.1"
  34. else
  35. PYENV_VERSION="3.5.1"
  36. fi
  37. # In order to work with ycmd, python *must* be built as a shared library. This
  38. # is set via the PYTHON_CONFIGURE_OPTS option.
  39. export PYTHON_CONFIGURE_OPTS="--enable-shared"
  40. pyenv install --skip-existing ${PYENV_VERSION}
  41. pyenv rehash
  42. pyenv global ${PYENV_VERSION}
  43. # It is quite easy to get the above series of steps wrong. Verify that the
  44. # version of python actually in the path and used is the version that was
  45. # requested, and fail the build if we broke the travis setup
  46. python_version=$(python -c 'import sys; print( "{0}.{1}".format( sys.version_info[0], sys.version_info[1] ) )')
  47. echo "Checking python version (actual ${python_version} vs expected ${YCM_PYTHON_VERSION})"
  48. test ${python_version} == ${YCM_PYTHON_VERSION}
  49. pip install -r python/test_requirements.txt
  50. # The build infrastructure prints a lot of spam after this script runs, so make
  51. # sure to disable printing, and failing on non-zero exit code after this script
  52. # finishes
  53. set +ev