From 91ebf08babb78dccd0f44808295b1ef10fb6bafa Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Thu, 11 Feb 2016 22:15:57 +0000 Subject: [PATCH] Factor the pyenv logic out of the platform-specific layer --- ci/travis/travis_install.linux.sh | 29 ---------------------- ci/travis/travis_install.osx.sh | 40 ++++--------------------------- ci/travis/travis_install.sh | 28 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 64 deletions(-) diff --git a/ci/travis/travis_install.linux.sh b/ci/travis/travis_install.linux.sh index 9106a7b7f7..d25efaee6f 100644 --- a/ci/travis/travis_install.linux.sh +++ b/ci/travis/travis_install.linux.sh @@ -1,34 +1,5 @@ # Linux-specific installation -############# -# pyenv setup -############# - -# DON'T exit if error -set +e -git clone https://github.com/yyuu/pyenv.git ~/.pyenv -git fetch --tags -git checkout v20160202 -# Exit if error -set -e - -export PYENV_ROOT="$HOME/.pyenv" -export PATH="$PYENV_ROOT/bin:$PATH" - -eval "$(pyenv init -)" - -if [ "${YCMD_PYTHON_VERSION}" == "2.6" ]; then - PYENV_VERSION="2.6.6" -elif [ "${YCMD_PYTHON_VERSION}" == "2.7" ]; then - PYENV_VERSION="2.7.6" -else - PYENV_VERSION="3.3.0" -fi - -pyenv install --skip-existing ${PYENV_VERSION} -pyenv rehash -pyenv global ${PYENV_VERSION} - # We can't use sudo, so we have to approximate the behaviour of the following: # $ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.7 100 diff --git a/ci/travis/travis_install.osx.sh b/ci/travis/travis_install.osx.sh index d50ebb0993..cfb5b6784c 100644 --- a/ci/travis/travis_install.osx.sh +++ b/ci/travis/travis_install.osx.sh @@ -4,16 +4,16 @@ # it twice to workaround. https://github.com/Homebrew/homebrew/issues/42553 brew update || brew update -# List of homebrew formulae to install in the order they appear" +# List of homebrew formulae to install in the order they appear. +# We require node, go and ninja for our build and tests, and all the others are +# dependencies of pyenv. REQUIREMENTS="node.js go ninja readline autoconf pkg-config - openssl - pyenv" - + openssl" # Install node, go, ninja, pyenv and dependencies for pkg in $REQUIREMENTS; do @@ -21,37 +21,7 @@ for pkg in $REQUIREMENTS; do brew install $pkg || brew outdated $pkg || brew upgrade $pkg done -# We use homebrew's defaults for PYENV_ROOT etc. -eval "$(pyenv init -)" - -if [ "${YCMD_PYTHON_VERSION}" == "2.6" ]; then - PYENV_VERSION="2.6.6" -elif [ "${YCMD_PYTHON_VERSION}" == "2.7" ]; then - PYENV_VERSION="2.7.6" -else - PYENV_VERSION="3.3.0" -fi - # In order to work with ycmd, python *must* be built as a shared library. The # most compatible way to do this on OS X is with --enable-framework. This is # set via the PYTHON_CONFIGURE_OPTS option -PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install --skip-existing ${PYENV_VERSION} -pyenv rehash -pyenv global ${PYENV_VERSION} - -YCMD_VENV_DIR=${HOME}/venvs/ycmd_test - -# virtualenv is not installed by default on OS X under python2.6, and we don't -# have sudo, so we install it manually. There is no "latest" link, so we have -# to install a specific version. -VENV_VERSION=14.0.6 - -curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-${VENV_VERSION}.tar.gz -tar xvfz virtualenv-${VENV_VERSION}.tar.gz -python virtualenv-${VENV_VERSION}/virtualenv.py -p python${YCMD_PYTHON_VERSION} ${YCMD_VENV_DIR} - -# virtualenv script is noisy, so don't print every command -set +v -source ${YCMD_VENV_DIR}/bin/activate -set -v - +export PYTHON_CONFIGURE_OPTS="--enable-framework" diff --git a/ci/travis/travis_install.sh b/ci/travis/travis_install.sh index 0c0d17b671..bed096f525 100644 --- a/ci/travis/travis_install.sh +++ b/ci/travis/travis_install.sh @@ -11,6 +11,34 @@ set -ev # - setup the correct python for $YCMD_PYTHON_VERSION source ci/travis/travis_install.${TRAVIS_OS_NAME}.sh +############# +# pyenv setup +############# + +# DON'T exit if error +set +e +git clone https://github.com/yyuu/pyenv.git ~/.pyenv +git fetch --tags +git checkout v20160202 +# Exit if error +set -e + +export PYENV_ROOT="$HOME/.pyenv" +export PATH="$PYENV_ROOT/bin:$PATH" + +eval "$(pyenv init -)" + +if [ "${YCMD_PYTHON_VERSION}" == "2.6" ]; then + PYENV_VERSION="2.6.6" +elif [ "${YCMD_PYTHON_VERSION}" == "2.7" ]; then + PYENV_VERSION="2.7.6" +else + PYENV_VERSION="3.3.0" +fi + +pyenv install --skip-existing ${PYENV_VERSION} +pyenv rehash +pyenv global ${PYENV_VERSION} # It is quite easy to get the above series of steps wrong. Verify that the # version of python actually in the path and used is the version that was