diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index e7c49f9..135b1ee 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -281,7 +281,21 @@ STATUS=0 # change to cache directory to reuse them between invocation. mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}" cd "${PYENV_VIRTUALENV_CACHE_PATH}" -venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?" +venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" && { + if virtualenv_is_pyvenv; then + [ -n "${EZ_SETUP_URL}" ] || EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/raw/${SETUPTOOLS_VERSION:-0.7.4}/ez_setup.py" + PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python -c 'import setuptools' 1>/dev/null 2>&1 || { + echo "Installing setuptools from ${EZ_SETUP_URL}..." 1>&2 + http get "${EZ_SETUP_URL}" | PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python + } + + [ -n "${GET_PIP_URL}" ] || GET_PIP_URL="https://raw.github.com/pypa/pip/${PIP_VERSION:-master}/contrib/get-pip.py" + PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-which pip 1>/dev/null 2>&1 || { + echo "Installing pip from ${GET_PIP_URL}..." 1>&2 + http get "${GET_PIP_URL}" | PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python + } + fi +} || STATUS="$?" # Create symlink of `python' bound for actual executable # TODO: remove this if virtualenv doesn't really need this @@ -292,18 +306,6 @@ if [ ! -e "${VIRTUALENV_PATH}/bin/python" ]; then fi fi -if virtualenv_is_pyvenv; then - [ -n "${EZ_SETUP_URL}" ] || EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/raw/${SETUPTOOLS_VERSION:-0.7.4}/ez_setup.py" - PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python -c 'import setuptools' 1>/dev/null 2>&1 || { - http get "${EZ_SETUP_URL}" | PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python - } - - [ -n "${GET_PIP_URL}" ] || GET_PIP_URL="https://raw.github.com/pypa/pip/${PIP_VERSION:-master}/contrib/get-pip.py" - PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-which pip 1>/dev/null 2>&1 || { - http get "${GET_PIP_URL}" | PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python - } -fi - ## Migrate previously installed packages from requirements.txt if [ -n "$UPGRADE" ]; then UPGRADE_STATUS=0