Skip to content

Commit

Permalink
Factor the pyenv logic out of the platform-specific layer
Browse files Browse the repository at this point in the history
  • Loading branch information
puremourning committed Feb 11, 2016
1 parent 4995195 commit 91ebf08
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 64 deletions.
29 changes: 0 additions & 29 deletions 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

Expand Down
40 changes: 5 additions & 35 deletions ci/travis/travis_install.osx.sh
Expand Up @@ -4,54 +4,24 @@
# 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
# Install package, or upgrade it if it is already installed
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"
28 changes: 28 additions & 0 deletions ci/travis/travis_install.sh
Expand Up @@ -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
Expand Down

0 comments on commit 91ebf08

Please sign in to comment.