diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b1257cd --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [pyenv] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: pyenv # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://www.bountysource.com/teams/pyenv-virtualenv/issues'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..39d447f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,29 @@ +Too many issues will kill our team's development velocity, drastically. +Make sure you have checked all steps below. + +### Prerequisite +* [ ] Make sure your problem is not listed in [the common build problems](https://github.com/pyenv/pyenv/wiki/Common-build-problems). +* [ ] Make sure no duplicated issue has already been reported in [the pyenv-virtualenv issues](https://github.com/pyenv/pyenv-virtualenv/issues). You should look in closed issues, too. +* [ ] Make sure you are not asking us to help solving your specific issue. + * GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like [Gitter](https://gitter.im/yyuu/pyenv), [StackOverflow](https://stackoverflow.com/questions/tagged/pyenv), etc. +* [ ] Make sure your problem is not derived from packaging (e.g. [Homebrew](https://brew.sh)). + * Please refer to the package documentation for the installation issues, etc. +* [ ] Make sure your problem is not derived from other plugins. + * This repository is maintaining the `pyenv-virtualenv` plugin only. Please refrain from reporting issues of other plugins here. + +### Description +- [ ] Platform information (e.g. Ubuntu Linux 20.04): +- [ ] OS architecture (e.g. amd64): +- [ ] pyenv version: +- [ ] pyenv-virtualenv version: +- [ ] Python version: +- [ ] virtualenv version (if installed): +- [ ] Please attach the debug log of a faulty Pyenv invocation as a gist + * If the problem happens in a Pyenv invocation, you can turn on debug logging by setting `PYENV_DEBUG=1`, e.g. `env PYENV_DEBUG=1 pyenv install -v 3.6.4` + * If the problem happens outside of a Pyenv invocation, get the debug log like this: + ``` + export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + set -x + + set +x + ``` diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 0000000..3f677a3 --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,13 @@ +# Configuration for probot-no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an Issue is closed for lack of response +daysUntilClose: 30 +# Label requiring a response +responseRequiredLabel: need-feedback +# Comment to post when closing an Issue for lack of response. Set to `false` to disable +closeComment: > + This issue has been automatically closed because there has been no response + to our request for more information from the original author. With only the + information that is currently in the issue, we don't have enough information + to take action. Please reach out if you have or find the answers we need so + that we can investigate further. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..59cf7d4 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: tests +on: [pull_request, push] +jobs: + tests: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + - ubuntu-20.04 + - macos-12 + - macos-11 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + # Normally, we would use the superbly maintained... + # - uses: actions/setup-python@v2 + # with: + # python-version: ${{ matrix.python-version }} + # ... but in the repo, we want to test pyenv builds on Ubuntu + # - run: | + # sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \ + # libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ + # xz-utils tk-dev libffi-dev liblzma-dev python-openssl git + # https://github.com/pyenv/pyenv#installation + #- env: + # PYENV_ROOT: /home/runner/work/pyenv/pyenv + # run: | + # echo $PYENV_ROOT + # echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH + # macos-11 Github Actions env has an old `readlink` and lacks `greadlink` which causes Bats to break + - run: | + if [[ $RUNNER_OS == "macOS" ]] && [[ $(sw_vers -productVersion | awk -F. '{print $1}') -lt 12 ]]; then + brew install coreutils + fi + - run: git clone https://github.com/bats-core/bats-core.git --depth=1 -b v1.2.0 bats + - run: bats/bin/bats --tap test diff --git a/.gitignore b/.gitignore index c860e56..75a199c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/bats/ /libexec/pyenv-virtualenv/*/*.class /libexec/pyenv-virtualenv/*/*.pyc /libexec/pyenv-virtualenv/*/*.pyo diff --git a/.travis.yml b/.travis.yml index 64342c6..b7849da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false -install: git clone https://github.com/sstephenson/bats.git +install: git clone --depth=1 https://github.com/sstephenson/bats.git script: bats/bin/bats --tap test language: c notifications: diff --git a/CHANGELOG.md b/CHANGELOG.md index 769b5f6..cda5b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ #### 1.1.4 * Support newer conda (#290) -* Prefer `python3.x` executable if avaialble (#206, #282, #296) +* Prefer `python3.x` executable if available (#206, #282, #296) #### 1.1.3 diff --git a/README.md b/README.md index be0e3f3..995bdcd 100644 --- a/README.md +++ b/README.md @@ -37,20 +37,17 @@ From inside that directory you can: 2. (OPTIONAL) **Add `pyenv virtualenv-init` to your shell** to enable auto-activation of virtualenvs. This is entirely optional but pretty useful. See "Activate virtualenv" below. ```sh - $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile + $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc ``` **Fish shell note**: Add this to your `~/.config/fish/config.fish` ```sh - status --is-interactive; and pyenv init - | source status --is-interactive; and pyenv virtualenv-init - | source ``` - **Zsh note**: Modify your `~/.zshenv` file instead of `~/.bash_profile`. + **Zsh note**: Modify your `~/.zshrc` file instead of `~/.bashrc`. - **Pyenv note**: You may also need to add `eval "$(pyenv init -)"` to your profile if you haven't done so already. - 3. **Restart your shell to enable pyenv-virtualenv** ```sh @@ -78,12 +75,13 @@ Or, if you would like to install the latest development release: $ brew install --HEAD pyenv-virtualenv ``` -After installation, you'll still need to add +After installation, you'll still need to do +[Pyenv shell setup steps](https://github.com/pyenv/pyenv#basic-github-checkout) +then add ```sh -eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" ``` -to your profile (as stated in the caveats). You'll only ever have to do this once. +to your shell's `.rc` file (as stated in the caveats). You'll only ever have to do this once. ## Usage @@ -101,6 +99,9 @@ $ pyenv virtualenv 2.7.10 my-virtual-env-2.7.10 will create a virtualenv based on Python 2.7.10 under `$(pyenv root)/versions` in a folder called `my-virtual-env-2.7.10`. +`pyenv virtualenv` forwards any options to the underlying command that actually +creates the virtual environment (`conda`, `virtualenv`, or `python -m venv`). +See the output of `pyenv virtualenv --help` for details. ### Create virtualenv from current version diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 144a3f4..50aad56 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -52,13 +52,18 @@ while [ $# -gt 0 ]; do shift 1 done +get_current_versions() { + local IFS=: + current_versions=($(pyenv-version-name 2>/dev/null)) +} + no_shell= versions=("$@") +current_versions=() if [ -z "${versions}" ]; then no_shell=1 - OLDIFS="$IFS" - IFS=: versions=($(pyenv-version-name 2>/dev/null)) - IFS="$OLDIFS" + get_current_versions + versions=("${current_versions[@]}") fi if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then @@ -84,9 +89,7 @@ fi if ! pyenv-virtualenv-prefix "${venv}" 1>/dev/null 2>&1; then # fallback to virtualenv of current version - OLDIFS="$IFS" - IFS=: current_versions=($(pyenv-version-name)) - IFS="$OLDIFS" + [ -n "${current_versions}" ] || get_current_versions new_venv="${current_versions%/envs/*}/envs/${venv}" if pyenv-virtualenv-prefix "${new_venv}" 1>/dev/null 2>&1; then venv="${new_venv}" @@ -228,8 +231,8 @@ if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2 fi cat </dev/null 2>&1; then @@ -479,16 +483,28 @@ if [ -z "${GET_PIP_URL}" ]; then # Use custom get-pip URL based on the target version (#1127) case "${PYENV_VERSION}" in 2.6 | 2.6.* ) - GET_PIP_URL="https://bootstrap.pypa.io/2.6/get-pip.py" + GET_PIP_URL="https://bootstrap.pypa.io/pip/2.6/get-pip.py" + ;; + 2.7 | 2.7.* ) + GET_PIP_URL="https://bootstrap.pypa.io/pip/2.7/get-pip.py" ;; 3.2 | 3.2.* ) - GET_PIP_URL="https://bootstrap.pypa.io/3.2/get-pip.py" + GET_PIP_URL="https://bootstrap.pypa.io/pip/3.2/get-pip.py" ;; 3.3 | 3.3.* ) - GET_PIP_URL="https://bootstrap.pypa.io/3.3/get-pip.py" + GET_PIP_URL="https://bootstrap.pypa.io/pip/3.3/get-pip.py" + ;; + 3.4 | 3.4.* ) + GET_PIP_URL="https://bootstrap.pypa.io/pip/3.4/get-pip.py" + ;; + 3.5 | 3.5.* ) + GET_PIP_URL="https://bootstrap.pypa.io/pip/3.5/get-pip.py" + ;; + 3.6 | 3.6.* ) + GET_PIP_URL="https://bootstrap.pypa.io/pip/3.6/get-pip.py" ;; * ) - GET_PIP_URL="https://bootstrap.pypa.io/get-pip.py" + GET_PIP_URL="https://bootstrap.pypa.io/pip/get-pip.py" ;; esac fi diff --git a/bin/pyenv-virtualenv-delete b/bin/pyenv-virtualenv-delete index 99d23d4..5fe1a46 100755 --- a/bin/pyenv-virtualenv-delete +++ b/bin/pyenv-virtualenv-delete @@ -75,7 +75,7 @@ else if pyenv-virtualenv-prefix "${VERSION_NAME}" 1>/dev/null 2>&1; then PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}" unset COMPAT_PREFIX - else + elif [ -z "$FORCE" ]; then echo "pyenv-virtualenv: \`${DEFINITION}' is not a virtualenv." 1>&2 exit 1 fi @@ -88,7 +88,7 @@ if [ -z "$FORCE" ]; then exit 1 fi - read -p "pyenv-virtualenv: remove $PREFIX? " + read -p "pyenv-virtualenv: remove $PREFIX? (y/N) " case "$REPLY" in y* | Y* ) ;; * ) exit 1 ;; diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 765b8da..a24a785 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -50,7 +50,7 @@ fi if [ -z "$print" ]; then case "$shell" in bash ) - profile='~/.bash_profile' + profile='~/.bashrc' ;; zsh ) profile='~/.zshrc' @@ -86,6 +86,8 @@ fi case "$shell" in fish ) cat <&2 + exit 1 + fi + resolve_link() { + $READLINK -f "$1" + } + script_path=$(resolve_link ${BASH_SOURCE}) +else + script_path=${BASH_SOURCE} +fi + +. ${script_path%/*}/../libexec/pyenv-virtualenv-realpath if [ -z "$PYENV_ROOT" ]; then PYENV_ROOT="${HOME}/.pyenv" diff --git a/bin/pyenv-virtualenvs b/bin/pyenv-virtualenvs index 173278b..fec1286 100755 --- a/bin/pyenv-virtualenvs +++ b/bin/pyenv-virtualenvs @@ -7,7 +7,21 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x -. "${BASH_SOURCE%/*}"/../libexec/pyenv-virtualenv-realpath +if [ -L "${BASH_SOURCE}" ]; then + READLINK=$(type -p greadlink readlink | head -1) + if [ -z "$READLINK" ]; then + echo "pyenv: cannot find readlink - are you missing GNU coreutils?" >&2 + exit 1 + fi + resolve_link() { + $READLINK -f "$1" + } + script_path=$(resolve_link ${BASH_SOURCE}) +else + script_path=${BASH_SOURCE} +fi + +. ${script_path%/*}/../libexec/pyenv-virtualenv-realpath if [ -z "$PYENV_ROOT" ]; then PYENV_ROOT="${HOME}/.pyenv" @@ -76,6 +90,7 @@ print_version() { num_versions=$((num_versions + 1)) } +shopt -s dotglob shopt -s nullglob for path in "$versions_dir"/*; do if [ -d "$path" ]; then @@ -96,6 +111,7 @@ for path in "$versions_dir"/*; do done fi done +shopt -u dotglob shopt -u nullglob if [ "$num_versions" -eq 0 ] && [ -n "$include_system" ]; then diff --git a/etc/pyenv.d/uninstall/envs.bash b/etc/pyenv.d/uninstall/envs.bash index c3dc5df..38bd1d9 100644 --- a/etc/pyenv.d/uninstall/envs.bash +++ b/etc/pyenv.d/uninstall/envs.bash @@ -2,29 +2,31 @@ resolve_link() { $(type -p greadlink readlink | head -1) "$1" } -if [ -n "${DEFINITION}" ]; then - if [[ "${DEFINITION}" != "${DEFINITION%/envs/*}" ]]; then - # Uninstall virtualenv by long name - exec pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}" - exit 128 - else - VERSION_NAME="${VERSION_NAME:-${DEFINITION##*/}}" - PREFIX="${PREFIX:-${PYENV_ROOT}/versions/${VERSION_NAME}}" - if [ -L "${PREFIX}" ]; then - REAL_PREFIX="$(resolve_link "${PREFIX}" 2>/dev/null || true)" - REAL_DEFINITION="${REAL_PREFIX#${PYENV_ROOT}/versions/}" - if [[ "${REAL_DEFINITION}" != "${REAL_DEFINITION%/envs/*}" ]]; then - # Uninstall virtualenv by short name - exec pyenv-virtualenv-delete ${FORCE+-f} "${REAL_DEFINITION}" - exit 128 - fi +uninstall_related_virtual_env() { + if [ -n "${DEFINITION}" ]; then + if [[ "${DEFINITION}" != "${DEFINITION%/envs/*}" ]]; then + # Uninstall virtualenv by long name + pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}" else - # Uninstall all virtualenvs inside `envs` directory too - shopt -s nullglob - for virtualenv in "${PREFIX}/envs/"*; do - pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}/envs/${virtualenv##*/}" - done - shopt -u nullglob + VERSION_NAME="${VERSION_NAME:-${DEFINITION##*/}}" + PREFIX="${PREFIX:-${PYENV_ROOT}/versions/${VERSION_NAME}}" + if [ -L "${PREFIX}" ]; then + REAL_PREFIX="$(resolve_link "${PREFIX}" 2>/dev/null || true)" + REAL_DEFINITION="${REAL_PREFIX#${PYENV_ROOT}/versions/}" + if [[ "${REAL_DEFINITION}" != "${REAL_DEFINITION%/envs/*}" ]]; then + # Uninstall virtualenv by short name + pyenv-virtualenv-delete ${FORCE+-f} "${REAL_DEFINITION}" + fi + else + # Uninstall all virtualenvs inside `envs` directory too + shopt -s nullglob + for virtualenv in "${PREFIX}/envs/"*; do + pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}/envs/${virtualenv##*/}" + done + shopt -u nullglob + fi fi fi -fi +} + +before_uninstall "uninstall_related_virtual_env" diff --git a/libexec/pyenv-virtualenv-realpath b/libexec/pyenv-virtualenv-realpath index 8a70128..de0bf5f 100644 --- a/libexec/pyenv-virtualenv-realpath +++ b/libexec/pyenv-virtualenv-realpath @@ -3,7 +3,7 @@ # Usage: . pyenv-virtualenv-realpath if ! { - enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath || + enable -f "${BASH_SOURCE%/*}"/../../../libexec/pyenv-realpath.dylib realpath || type realpath } >/dev/null 2>&1; then if [ -n "$PYENV_NATIVE_EXT" ]; then diff --git a/test/activate.bats b/test/activate.bats index 88dc493..c32b342 100644 --- a/test/activate.bats +++ b/test/activate.bats @@ -34,8 +34,8 @@ deactivated export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv) \${PS1:-}"; EOS unstub pyenv-version-name @@ -59,8 +59,8 @@ EOS deactivated export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv) \${PS1:-}"; EOS unstub pyenv-version-name @@ -87,8 +87,8 @@ pyenv-virtualenv: activate venv export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv) \${PS1:-}"; EOS unstub pyenv-version-name @@ -115,8 +115,8 @@ export PYENV_ACTIVATE_SHELL=1; export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv) \${PS1:-}"; EOS unstub pyenv-version-name @@ -192,8 +192,8 @@ export PYENV_ACTIVATE_SHELL=1; export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv27) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv27) \${PS1:-}"; EOS unstub pyenv-virtualenv-prefix @@ -218,8 +218,8 @@ export PYENV_ACTIVATE_SHELL=1; export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv27) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv27) \${PS1:-}"; EOS unstub pyenv-virtualenv-prefix @@ -391,8 +391,8 @@ export PYENV_ACTIVATE_SHELL=1; export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(venv27) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(venv27) \${PS1:-}"; EOS unstub pyenv-sh-deactivate diff --git a/test/conda-activate.bats b/test/conda-activate.bats index 89e2001..a58917f 100644 --- a/test/conda-activate.bats +++ b/test/conda-activate.bats @@ -37,8 +37,8 @@ export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0"; export CONDA_DEFAULT_ENV="root"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(anaconda-2.3.0) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(anaconda-2.3.0) \${PS1:-}"; export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0"; EOS @@ -96,8 +96,8 @@ export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1"; export CONDA_DEFAULT_ENV="root"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(miniconda-3.9.1) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(miniconda-3.9.1) \${PS1:-}"; export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1"; EOS @@ -126,8 +126,8 @@ export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo"; export CONDA_DEFAULT_ENV="foo"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(anaconda-2.3.0/envs/foo) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(anaconda-2.3.0/envs/foo) \${PS1:-}"; export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0/envs/foo"; . "${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo/etc/conda/activate.d/activate.sh"; EOS @@ -159,8 +159,8 @@ export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar"; export VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar"; export CONDA_DEFAULT_ENV="bar"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. -export _OLD_VIRTUAL_PS1="\${PS1}"; -export PS1="(miniconda-3.9.1/envs/bar) \${PS1}"; +export _OLD_VIRTUAL_PS1="\${PS1:-}"; +export PS1="(miniconda-3.9.1/envs/bar) \${PS1:-}"; export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1/envs/bar"; . "${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar/etc/conda/activate.d/activate.sh"; EOS diff --git a/test/conda-deactivate.bats b/test/conda-deactivate.bats index 4eeaf3b..2abab60 100644 --- a/test/conda-deactivate.bats +++ b/test/conda-deactivate.bats @@ -34,15 +34,15 @@ unset CONDA_PREFIX unset PYENV_VIRTUAL_ENV; unset VIRTUAL_ENV; unset CONDA_DEFAULT_ENV; -if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then +if [ -n "\${_OLD_VIRTUAL_PATH:-}" ]; then export PATH="\${_OLD_VIRTUAL_PATH}"; unset _OLD_VIRTUAL_PATH; fi; -if [ -n "\${_OLD_VIRTUAL_PYTHONHOME}" ]; then +if [ -n "\${_OLD_VIRTUAL_PYTHONHOME:-}" ]; then export PYTHONHOME="\${_OLD_VIRTUAL_PYTHONHOME}"; unset _OLD_VIRTUAL_PYTHONHOME; fi; -if [ -n "\${_OLD_VIRTUAL_PS1}" ]; then +if [ -n "\${_OLD_VIRTUAL_PS1:-}" ]; then export PS1="\${_OLD_VIRTUAL_PS1}"; unset _OLD_VIRTUAL_PS1; fi; @@ -102,15 +102,15 @@ unset CONDA_PREFIX unset PYENV_VIRTUAL_ENV; unset VIRTUAL_ENV; unset CONDA_DEFAULT_ENV; -if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then +if [ -n "\${_OLD_VIRTUAL_PATH:-}" ]; then export PATH="\${_OLD_VIRTUAL_PATH}"; unset _OLD_VIRTUAL_PATH; fi; -if [ -n "\${_OLD_VIRTUAL_PYTHONHOME}" ]; then +if [ -n "\${_OLD_VIRTUAL_PYTHONHOME:-}" ]; then export PYTHONHOME="\${_OLD_VIRTUAL_PYTHONHOME}"; unset _OLD_VIRTUAL_PYTHONHOME; fi; -if [ -n "\${_OLD_VIRTUAL_PS1}" ]; then +if [ -n "\${_OLD_VIRTUAL_PS1:-}" ]; then export PS1="\${_OLD_VIRTUAL_PS1}"; unset _OLD_VIRTUAL_PS1; fi; diff --git a/test/deactivate.bats b/test/deactivate.bats index ad8f553..53ed0cb 100644 --- a/test/deactivate.bats +++ b/test/deactivate.bats @@ -1,4 +1,4 @@ -#!/usr/bin/env bats + #!/usr/bin/env bats load test_helper @@ -30,15 +30,15 @@ setup() { assert_output </dev/null 2>&1; then - unset -f deactivate; -fi; -EOS -} - -@test "deactivate virtualenv (quiet)" { - export PYENV_VIRTUALENV_INIT=1 - export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv" - export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv" - export PYENV_ACTIVATE_SHELL= - - PYENV_SHELL="bash" run pyenv-sh-deactivate --quiet - - assert_success - assert_output <