diff --git a/install_rally.sh b/install_rally.sh index 1184816ee3..b428036916 100755 --- a/install_rally.sh +++ b/install_rally.sh @@ -273,26 +273,26 @@ download() { wget -nv $VERBOSE --no-check-certificate -O "$@"; } -download_from_pypi () { - local pkg=$1 +download_setuptools () { + local url + # NOTE(stpierre): This (admittedly ugly) one-liner parses the JSON + # returned from pypi and fetches the URL for the latest version of + # the source (i.e., .tar.gz) package. It's safe here to look for + # the .tar.gz explicitly (rather than matching on package type == + # source) because we untar it later anyway. + url=$(python -c ' +import json +import urllib2 - # NOTE(amaretskiy): get packages list in HTML - local packages=$(download - "${BASE_PIP_URL}/${pkg}/") - - # NOTE(amaretskiy): filter packages URLs - packages=$(echo ${packages} | sed -En "s/.*href=\"(.*${pkg}-.*\\.gz)\#.*/\1/p") - - # NOTE(amaretskiy): sort packages URLs by their version part - packages=$(echo ${packages} | sort -t / -k 7 -V) - - # NOTE(amaretskiy): finally, the URL is in the last line - local url=$(echo ${packages} | tail -1) +print [u["url"] + for u in json.load(urllib2.urlopen("http://pypi.python.org/pypi/setuptools/json/"))["urls"] + if u["filename"].endswith(".tar.gz")].pop()') if [ -n "$url" ]; then - download "$(basename "$url")" "$BASE_PIP_URL"/"$pkg"/"$url" + download "$(basename "$url")" "$url" else - die $EX_PROTOCOL "Package '$pkg' not found on PyPI!" <<__EOF__ -Unable to download package '$pkg' from PyPI. + die $EX_PROTOCOL "Setuptools not found on PyPI!" <<__EOF__ +Unable to download package 'setuptools' from PyPI. __EOF__ fi } @@ -446,7 +446,7 @@ __EOF__ # Wheel installs require setuptools >= 0.8 for dist-info support. # if pip wheel --help 1>/dev/null 2>/dev/null; then - (cd "$DESTDIR" && download_from_pypi setuptools) + (cd "$DESTDIR" && download_setuptools) # setup.py must be called with `python', which will be the # python executable inside the virtualenv, not `$PYTHON', # which is the system python.