Repository: mesos Updated Branches: refs/heads/master 81a7b5f68 -> d7eb8a9a9
Updated build-virtualenv to use Python 3 features. With Python 3, virtualenv is built-in. We thus remove the error messages if the script is run using Python 3 without virtualenv installed on the machine. We also use `python` instead of `virtualenv` to build the virtual environment. This change also fixes an issue on my computer where running `build-virtualenv` with Python 3 displayed an error message: `ModuleNotFoundError: No module named 'nodeenv'`. Review: https://reviews.apache.org/r/67853/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d7eb8a9a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d7eb8a9a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d7eb8a9a Branch: refs/heads/master Commit: d7eb8a9a96b7abadd9dd778604f16383567369f9 Parents: 81a7b5f Author: Armand Grillet <agril...@mesosphere.io> Authored: Mon Jul 9 18:03:30 2018 +0200 Committer: Kevin Klues <klue...@gmail.com> Committed: Mon Jul 9 18:08:56 2018 +0200 ---------------------------------------------------------------------- support/build-virtualenv | 62 ++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/d7eb8a9a/support/build-virtualenv ---------------------------------------------------------------------- diff --git a/support/build-virtualenv b/support/build-virtualenv index 5fda081..b47f730 100755 --- a/support/build-virtualenv +++ b/support/build-virtualenv @@ -26,47 +26,55 @@ if [ "${OLD_VIRTUAL_ENV}" != "" ]; then exit 1 fi -# Verify that python and virtualenv are installed. +# Verify that python is installed. if [ "${PYTHON}" = "" ]; then - echo "You must have python installed in order to continue..." + echo "You must have python installed in order to continue." exit 1 fi -if [ "${VIRTUALENV}" = "" ]; then - # Search for a locally installed virtualenv. - # See https://docs.python.org/2/library/site.html#site.USER_SITE for details. - VIRTUALENV=$(${PYTHON} -c "import site; print site.USER_SITE")/virtualenv.py - - if [ ! -f "${VIRTUALENV}" ]; then - echo "You must have virtualenv installed in order to continue..." - exit 1 - fi -fi - PYTHON_MAJOR=$(${PYTHON} -c 'import sys; print(sys.version_info[0])') PYTHON_MINOR=$(${PYTHON} -c 'import sys; print(sys.version_info[1])') -if [ "$MESOS_SUPPORT_PYTHON" = "3" ]; then - if [ "${PYTHON_MAJOR}" != "3" ] || [ "${PYTHON_MINOR}" -lt "6" ]; then - echo "You must be running python 3.6 in order to continue." - echo "Consider running as 'PYTHON=python3 <previous-command>' or similar." +if [ "${PYTHON_MAJOR}" = "3" ]; then + if [ "${PYTHON_MINOR}" -lt "6" ]; then + echo "You must be running python 3.6 or newer in order to continue." + echo "Consider running as 'PYTHON=python3 ${0}' or similar." exit 1 + else + # Set up a virtual environment for the linters. + ${PYTHON} -m venv --clear --prompt="${VIRTUALENV_NAME}" ${VIRTUALENV_DIRECTORY} fi -else - if [ "${PYTHON_MAJOR}" != "2" ] || [ "${PYTHON_MINOR}" -lt "6" ]; then +elif [ "${PYTHON_MAJOR}" = "2" ]; then + if [ "${PYTHON_MINOR}" -lt "6" ]; then echo "You must be running python 2.6 or 2.7 in order to continue." - echo "Consider running as 'PYTHON=python2 ./bootstrap' or similar." + echo "Consider running as 'PYTHON=python2 ${0} or similar." exit 1 + else + if [ "${VIRTUALENV}" = "" ]; then + # Search for a locally installed virtualenv. + # See https://docs.python.org/2/library/site.html#site.USER_SITE for details. + VIRTUALENV=$(${PYTHON} -c "import site; print site.USER_SITE")/virtualenv.py + fi + + if [ ! -f "${VIRTUALENV}" ]; then + echo "You must have virtualenv installed in order to continue..." + exit 1 + fi + + # Set up a virtual environment for the linters. + ${PYTHON} ${VIRTUALENV} --python=${PYTHON} \ + --clear \ + --no-site-packages \ + --prompt="(${VIRTUALENV_NAME}) " \ + ${VIRTUALENV_DIRECTORY} fi +else + echo "You must be running either python 2.6, 2.7," + echo "or python 3.6 or newer in order to continue." + echo "Consider running as 'PYTHON=python3 ${0}' or similar." + exit 1 fi -# Set up a virtual environment for the linters. -${PYTHON} ${VIRTUALENV} --python=${PYTHON} \ - --clear \ - --no-site-packages \ - --prompt="(${VIRTUALENV_NAME}) " \ - ${VIRTUALENV_DIRECTORY} || true - source ${VIRTUALENV_DIRECTORY}/bin/activate pip install --upgrade pip pip install -r ${CURRDIR}/pip-requirements.txt