Browse Source

Our Travis config now supports py3

Val Markovic 9 years ago
parent
commit
ba97a28b62
4 changed files with 101 additions and 40 deletions
  1. 41 9
      .travis.yml
  2. 0 1
      travis/travis_install.linux.sh
  3. 21 16
      travis/travis_install.osx.sh
  4. 39 14
      travis/travis_install.sh

+ 41 - 9
.travis.yml

@@ -11,18 +11,50 @@ install:
 script: ./run_tests.py
 env:
   matrix:
-    - YCMD_PYTHON_VERSION=2.7
-    - YCMD_PYTHON_VERSION=2.6
+    - YCM_PYTHON_VERSION=2.7
+    - YCM_PYTHON_VERSION=2.6
+    - YCM_PYTHON_VERSION=3.3
+matrix:
+  exclude:
+    - os: osx
+      env: YCM_PYTHON_VERSION=2.6
 addons:
   apt:
     sources:
-     - deadsnakes
+     # The Travis apt source whitelist can be found here:
+     #   https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
+     - ubuntu-toolchain-r-test  # for new libstdc++
+     - deadsnakes  # for various versions of python
+     - kalakris-cmake # for a more recent version of cmake (needed for ninja-build)
     packages:
-     - python2.6
-     - python2.6-dev
-     - python2.7
-     - python2.7-dev
-     - python-virtualenv
+     - cmake
+     - ninja-build
+     # The confusing part is that on Travis Linux with YCMD_PYTHON_VERSION=3.3,
+     # we build the C++ parts against the below system python3.3, but run
+     # against the pyenv python3.3. This is because stupid cmake 2.8.11 has a
+     # bug preventing it from finding the pyenv pythons (ostensibly; I haven't
+     # checked, but online reports say the issue is gone with cmake 3.4).
+     # Everything still works though, it's just weird.
+     - python3.3
+     - python3.3-dev
+     # Everything below is a Python build dep (though it depends on Python
+     # version). We need them because pyenv builds Python.
+     - libssl-dev
+     - zlib1g-dev
+     - libbz2-dev
+     - libreadline-dev
+     - libsqlite3-dev
+     - wget
+     - curl
+     - llvm
+     - libncurses5-dev
+     - libncursesw5-dev
 cache:
   directories:
-    - $HOME/.cache/pip
+    - $HOME/.cache/pip  # Python packages from pip
+    - $HOME/.npm  # Node packages from npm
+    - $HOME/.multirust  # What multirust downloads
+    - $HOME/.cargo  # Cargo package deps
+    - $HOME/.pyenv  # pyenv
+    - $TRAVIS_BUILD_DIR/clang_archives  # Clang downloads
+    - $TRAVIS_BUILD_DIR/third_party/racerd/target  # Racerd compilation

+ 0 - 1
travis/travis_install.linux.sh

@@ -1,3 +1,2 @@
 # Linux installation
 
-virtualenv -p python${YCMD_PYTHON_VERSION} ${YCMD_VENV_DIR}

+ 21 - 16
travis/travis_install.osx.sh

@@ -1,19 +1,24 @@
-# OS X installation
+# OS X-specific installation
 
-# OS X comes with 2 versions of python by default, and a neat system
-# (versioner) to switch between them:
-#   /usr/bin/python2.7 - python 2.7
-#   /usr/bin/python2.6 - python 2.6
-#
-# We just set the system default to match it
-# http://stackoverflow.com/q/6998545
-defaults write com.apple.versioner.python Version ${YCMD_PYTHON_VERSION}
+# There's a homebrew bug which causes brew update to fail the first time. Run
+# it twice to workaround. https://github.com/Homebrew/homebrew/issues/42553
+brew update || brew update
 
-# 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=13.1.2
+# List of homebrew formulae to install in the order they appear.
+# These are dependencies of pyenv.
+REQUIREMENTS="ninja
+              readline
+              autoconf
+              pkg-config
+              openssl"
 
-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}
+# 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
+
+# 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
+export PYTHON_CONFIGURE_OPTS="--enable-framework"

+ 39 - 14
travis/travis_install.sh

@@ -2,30 +2,55 @@
 
 set -ev
 
-YCMD_VENV_DIR=${HOME}/venvs/ycmd_test
+####################
+# OS-specific setup
+####################
 
 # Requirements of OS-specific install:
 #  - install any software which is not installed by Travis configuration
-#  - create (but don't activate) a virtualenv for the python version
-#    ${YCMD_PYTHON_VERSION} in the directory ${YCMD_VENV_DIR}, e.g.
-#    virtualenv -p python${YCMD_PYTHON_VERSION} ${YCMD_VENV_DIR}
+#  - set up everything necessary so that pyenv can build python
 source travis/travis_install.${TRAVIS_OS_NAME}.sh
 
-# virtualenv doesn't copy python-config https://github.com/pypa/virtualenv/issues/169
-# but our build system uses it
-cp /usr/bin/python${YCMD_PYTHON_VERSION}-config ${YCMD_VENV_DIR}/bin/python-config
+#############
+# pyenv setup
+#############
 
-# virtualenv script is noisy, so don't print every command
-set +v
-source ${YCMD_VENV_DIR}/bin/activate
-set -v
+# 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 [ "${YCM_PYTHON_VERSION}" == "2.6" ]; then
+  PYENV_VERSION="2.6.6"
+elif [ "${YCM_PYTHON_VERSION}" == "2.7" ]; then
+  PYENV_VERSION="2.7.6"
+else
+  PYENV_VERSION="3.3.6"
+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
 # requested, and fail the build if we broke the travis setup
-python_version=$(python -c 'import sys; print "{0}.{1}".format( sys.version_info[0], sys.version_info[1] )')
-echo "Checking python version (actual ${python_version} vs expected ${YCMD_PYTHON_VERSION})"
-test ${python_version} == ${YCMD_PYTHON_VERSION}
+python_version=$(python -c 'import sys; print( "{0}.{1}".format( sys.version_info[0], sys.version_info[1] ) )')
+echo "Checking python version (actual ${python_version} vs expected ${YCM_PYTHON_VERSION})"
+test ${python_version} == ${YCM_PYTHON_VERSION}
+
+
+############
+# pip setup
+############
 
 pip install -U pip wheel setuptools
 pip install -r python/test_requirements.txt