diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index 41b4708..5646d53 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -378,6 +378,23 @@ if [ -n "$UPGRADE" ]; then fi fi +if [ -z "${VIRTUALEN_VERSION}" ]; then + case "${PYENV_VERSION}" in + "3.0"* ) + NO_ENSUREPIP=1 + ;; + "3.1"* ) + NO_ENSUREPIP=1 + ;; + "3.2"* | "stackless-3.2"* ) + # pip 8.x (bundled with virtualenv 14+) doesn't support 3.2 anymore + # https://github.com/yyuu/pyenv/issues/531 + VIRTUALENV_VERSION="13.1.2" + NO_ENSUREPIP=1 + ;; + esac +fi + if [ -n "${USE_CONDA}" ]; then # e.g. `conda create -n py35 python=3.5 anaconda` if [ -n "${VIRTUALENV_PYTHON}" ]; then @@ -416,8 +433,12 @@ else fi fi if [ -z "${HAS_VIRTUALENV}" ]; then - VIRTUALENV_VERSION="==${VIRTUALENV_VERSION}" - pyenv-exec pip install $QUIET $VERBOSE "virtualenv${VIRTUALENV_VERSION%==}" + if [ -n "${VIRTUALENV_VERSION}" ]; then + virtualenv_spec="virtualenv==${VIRTUALENV_VERSION}" + else + virtualenv_spec="virtualenv" + fi + pyenv-exec pip install $QUIET $VERBOSE "${virtualenv_spec}" HAS_VIRTUALENV=1 fi fi diff --git a/test/delete.bats b/test/delete.bats index 3818aa5..fe5bd1d 100644 --- a/test/delete.bats +++ b/test/delete.bats @@ -23,8 +23,8 @@ setup() { } @test "delete virtualenv by symlink" { - mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27" - ln -fs "${PYENV_ROOT}/versions/2.7.10/envs/venv27" "${PYENV_ROOT}/versions/venv27" + mkdir -p "${PYENV_ROOT}/versions/2.7.11/envs/venv27" + ln -fs "${PYENV_ROOT}/versions/2.7.11/envs/venv27" "${PYENV_ROOT}/versions/venv27" stub pyenv-rehash "true" @@ -34,55 +34,55 @@ setup() { unstub pyenv-rehash - [ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ] + [ ! -d "${PYENV_ROOT}/versions/2.7.11/envs/venv27" ] [ ! -L "${PYENV_ROOT}/versions/venv27" ] } @test "delete virtualenv with symlink" { - mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27" - ln -fs "${PYENV_ROOT}/versions/2.7.10/envs/venv27" "${PYENV_ROOT}/versions/venv27" + mkdir -p "${PYENV_ROOT}/versions/2.7.11/envs/venv27" + ln -fs "${PYENV_ROOT}/versions/2.7.11/envs/venv27" "${PYENV_ROOT}/versions/venv27" stub pyenv-rehash "true" - run pyenv-virtualenv-delete -f "2.7.10/envs/venv27" + run pyenv-virtualenv-delete -f "2.7.11/envs/venv27" assert_success unstub pyenv-rehash - [ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ] + [ ! -d "${PYENV_ROOT}/versions/2.7.11/envs/venv27" ] [ ! -L "${PYENV_ROOT}/versions/venv27" ] } @test "not delete virtualenv with different symlink" { mkdir -p "${PYENV_ROOT}/versions/2.7.8/envs/venv27" - mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27" + mkdir -p "${PYENV_ROOT}/versions/2.7.11/envs/venv27" ln -fs "${PYENV_ROOT}/versions/2.7.8/envs/venv27" "${PYENV_ROOT}/versions/venv27" stub pyenv-rehash "true" - run pyenv-virtualenv-delete -f "2.7.10/envs/venv27" + run pyenv-virtualenv-delete -f "2.7.11/envs/venv27" assert_success unstub pyenv-rehash - [ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ] + [ ! -d "${PYENV_ROOT}/versions/2.7.11/envs/venv27" ] [ -L "${PYENV_ROOT}/versions/venv27" ] } @test "not delete virtualenv with same name" { - mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27" + mkdir -p "${PYENV_ROOT}/versions/2.7.11/envs/venv27" mkdir -p "${PYENV_ROOT}/versions/venv27" stub pyenv-rehash "true" - run pyenv-virtualenv-delete -f "2.7.10/envs/venv27" + run pyenv-virtualenv-delete -f "2.7.11/envs/venv27" assert_success unstub pyenv-rehash - [ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ] + [ ! -d "${PYENV_ROOT}/versions/2.7.11/envs/venv27" ] [ -d "${PYENV_ROOT}/versions/venv27" ] } diff --git a/test/envs.bats b/test/envs.bats index 4da2a75..57b6d94 100644 --- a/test/envs.bats +++ b/test/envs.bats @@ -19,28 +19,28 @@ unstub_pyenv() { } @test "path should be handled properly even if there is 'envs' in PYENV_ROOT" { - export PYENV_VERSION="3.4.1" - setup_pyvenv "3.4.1" + export PYENV_VERSION="3.5.1" + setup_pyvenv "3.5.1" stub_pyenv "${PYENV_VERSION}" stub pyenv-version-name "echo '${PYENV_VERSION}'" stub pyenv-prefix " : echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'" stub pyenv-virtualenv-prefix " : false" - stub pyenv-exec "pyvenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";mkdir -p \${PYENV_ROOT}/versions/3.4.1/envs/venv/bin" - stub pyenv-exec "python -s -m ensurepip : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";touch \${PYENV_ROOT}/versions/3.4.1/envs/venv/bin/pip" + stub pyenv-exec "pyvenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";mkdir -p \${PYENV_ROOT}/versions/3.5.1/envs/venv/bin" + stub pyenv-exec "python -s -m ensurepip : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";touch \${PYENV_ROOT}/versions/3.5.1/envs/venv/bin/pip" run pyenv-virtualenv venv assert_success assert_output <