From 13c633223ee8f4001049623de87c806ffc7f3b11 Mon Sep 17 00:00:00 2001 From: vitaut Date: Wed, 14 Oct 2015 08:17:39 -0700 Subject: [PATCH] Upgrade pip on Travis --- doc/build.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/doc/build.py b/doc/build.py index 7c1e649c..235e9afc 100755 --- a/doc/build.py +++ b/doc/build.py @@ -2,28 +2,22 @@ # Build the documentation. from __future__ import print_function -import os, shutil, tempfile +import os, pip, shutil, tempfile from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE +from distutils.version import LooseVersion def pip_install(package, commit=None, **kwargs): "Install package using pip." + if LooseVersion(pip.__version__) < LooseVersion('1.5.4'): + # Upgrade pip because installation of sphinx with pip 1.1 available on Travis + # is broken (see #207) and it doesn't support the show command. + check_call(['pip', 'install', '--upgrade', 'pip']) if commit: check_version = kwargs.get('check_version', '') - cmd = ['pip', 'show', package.split('/')[1]] - p = Popen(cmd, stdout=PIPE, stderr=PIPE) - stdout, stderr = p.communicate() - if stdout and check_version in stdout: + output = check_output(['pip', 'show', package.split('/')[1]]) + if check_version in output: print('{} already installed'.format(package)) return - if p.returncode != 0: - # Old versions of pip such as the one installed on Travis don't support - # the show command - continue installation in this case. - # Otherwise throw CalledProcessError. - if p.returncode > 1 and 'No command by the name pip show' not in stderr: - raise CalledProcessError(p.returncode, cmd) - else: - print('Uninstalling {}'.format(package)) - check_call('pip', 'uninstall', '-y', package) package = 'git+git://github.com/{0}.git@{1}'.format(package, commit) print('Installing {}'.format(package)) check_call(['pip', 'install', '--upgrade', package])