From 90f7b999ff064c99ad6f5eec015db82ac76d8429 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Sun, 9 May 2021 20:16:35 +0300 Subject: [PATCH 01/26] ~/.*rc should be modified instead of ~/.*profile Otherwise, there's no effect for non-login interactive shells --- README.md | 7 ++----- bin/pyenv-virtualenv-init | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index be0e3f3..07d8558 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 diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 765b8da..404ddde 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' From 8c7ef734f9689739a9787b2e40f6f63b26918d79 Mon Sep 17 00:00:00 2001 From: Anton Petrov Date: Sun, 9 May 2021 20:17:17 +0300 Subject: [PATCH 02/26] Update pyenv-virtualenv-init https://github.com/pyenv/pyenv-installer/pull/109 --- bin/pyenv-virtualenv-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 765b8da..404ddde 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' From 582b693c112ba2ab450228f84831a3d206b00d7a Mon Sep 17 00:00:00 2001 From: native-api Date: Wed, 26 May 2021 00:49:31 +0300 Subject: [PATCH 03/26] Fix installation steps to allow for Pyenv 2 The text included info on Pyenv startup which is now outdated and incorrect. Closes https://github.com/pyenv/pyenv/issues/1947, https://github.com/pyenv/pyenv-virtualenv/issues/387 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 07d8558..f7b4244 100644 --- a/README.md +++ b/README.md @@ -75,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 From b334dde5efade3a4cc8c6024652a621f004a10b8 Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Wed, 16 Jun 2021 15:20:14 +0530 Subject: [PATCH 04/26] Fix #394 - update pyenv virtualenvs command to list virtualenvs starting with dot prefixes --- bin/pyenv-virtualenvs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/pyenv-virtualenvs b/bin/pyenv-virtualenvs index 173278b..f9426bb 100755 --- a/bin/pyenv-virtualenvs +++ b/bin/pyenv-virtualenvs @@ -76,6 +76,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 +97,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 From ce08a8ee72d2cb667f793ab736fe98635043b33f Mon Sep 17 00:00:00 2001 From: native-api Date: Tue, 5 Oct 2021 01:29:37 +0300 Subject: [PATCH 05/26] Create ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..cc7e82e --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,22 @@ +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 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 debug log of a faulty Pyenv invocation as a gist + * You can turn on verbose debug logging using by setting `PYENV_DEBUG=1`, e.g. `env PYENV_DEBUG=1 pyenv install -v 3.6.4` From 2648a4af29f6f514226608518a07fc992d4cd2a5 Mon Sep 17 00:00:00 2001 From: native-api Date: Tue, 5 Oct 2021 01:30:31 +0300 Subject: [PATCH 06/26] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index cc7e82e..b933544 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -3,7 +3,7 @@ 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 issues](https://github.com/pyenv/pyenv-virtualenv/issues). You should look in closed issues, too. +* [ ] 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)). From 6fa056912bafdf123eeb7e6f88d50db89955b3b3 Mon Sep 17 00:00:00 2001 From: native-api Date: Tue, 5 Oct 2021 04:40:56 +0300 Subject: [PATCH 07/26] Create no-response.yml --- .github/no-response.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/no-response.yml 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. From afa008ec95f452535fafc45051fd16f214d38748 Mon Sep 17 00:00:00 2001 From: native-api Date: Fri, 8 Oct 2021 11:15:55 +0300 Subject: [PATCH 08/26] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b933544..39d447f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -18,5 +18,12 @@ Make sure you have checked all steps below. - [ ] pyenv-virtualenv version: - [ ] Python version: - [ ] virtualenv version (if installed): -- [ ] Please attach debug log of a faulty Pyenv invocation as a gist - * You can turn on verbose debug logging using by setting `PYENV_DEBUG=1`, e.g. `env PYENV_DEBUG=1 pyenv install -v 3.6.4` +- [ ] 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 + ``` From f95d6a9bee20076f6dc2298878ecfb1b2f6a972c Mon Sep 17 00:00:00 2001 From: native-api Date: Fri, 8 Oct 2021 11:55:00 +0300 Subject: [PATCH 09/26] Create FUNDING.yml --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml 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'] From c3110d874e7af321085a8647101c0103b6fb2a2c Mon Sep 17 00:00:00 2001 From: jivanf Date: Mon, 8 Nov 2021 07:14:47 -0800 Subject: [PATCH 10/26] Fix get-pip.py URLs for older versions of Python (#403) --- bin/pyenv-virtualenv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index 01a0ffc..00fd3eb 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -479,7 +479,10 @@ 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" From 5509c25ac1b09617848adbb517c8443580a82874 Mon Sep 17 00:00:00 2001 From: Seonghyeon Cho Date: Tue, 9 Nov 2021 00:15:23 +0900 Subject: [PATCH 11/26] Add (y/N) prompt help text (#404) --- bin/pyenv-virtualenv-delete | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pyenv-virtualenv-delete b/bin/pyenv-virtualenv-delete index 99d23d4..aa21410 100755 --- a/bin/pyenv-virtualenv-delete +++ b/bin/pyenv-virtualenv-delete @@ -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 ;; From 91609e25f3d93cde02ce8ed4325acb5428b6bf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 14 Nov 2021 01:30:56 +0200 Subject: [PATCH 12/26] perf(sh-activate): avoid a duplicate pyenv-version-name call (#380) --- bin/pyenv-sh-activate | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 7c28dca..b9e8e12 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}" From 1ee7ca6346ceb336760247330fa1faa6892d091b Mon Sep 17 00:00:00 2001 From: Alain Kalker Date: Sat, 29 Jan 2022 18:53:52 +0100 Subject: [PATCH 13/26] Fix unbound variable errors when running `pyenv activate` with `set -u` (#423) --- bin/pyenv-sh-deactivate | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/pyenv-sh-deactivate b/bin/pyenv-sh-deactivate index 90c3322..4793d6f 100755 --- a/bin/pyenv-sh-deactivate +++ b/bin/pyenv-sh-deactivate @@ -134,7 +134,7 @@ EOS ;; * ) cat < Date: Sun, 30 Jan 2022 19:14:28 +0100 Subject: [PATCH 14/26] Fix another unbound variable error (#424) * Fix tests failing after #423 --- bin/pyenv-sh-activate | 4 ++-- test/activate.bats | 28 ++++++++++++------------- test/conda-activate.bats | 16 +++++++-------- test/conda-deactivate.bats | 12 +++++------ test/deactivate.bats | 42 +++++++++++++++++++------------------- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index b9e8e12..08a666d 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -229,8 +229,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 < Date: Sat, 26 Feb 2022 01:41:41 -0500 Subject: [PATCH 15/26] Update `get-pip.py` URLs in `pyenv-virtualenv` (#426) --- bin/pyenv-virtualenv | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index 00fd3eb..b1bb20c 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -485,13 +485,22 @@ if [ -z "${GET_PIP_URL}" ]; then 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 From c6ff093344a3823d8b07c90a6478942d44d0392e Mon Sep 17 00:00:00 2001 From: "Eric N. Vander Weele" Date: Thu, 19 May 2022 12:03:51 -0400 Subject: [PATCH 16/26] Deduplicate shims in $PATH for the fish shell during initialization (#430) When a fish login shell is invoked within an existing login shell, avoid duplicating path to the shims by removing existing occurrences before prepending. --- bin/pyenv-virtualenv-init | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 404ddde..1a60c53 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -86,6 +86,8 @@ fi case "$shell" in fish ) cat < Date: Tue, 11 Oct 2022 01:34:24 +0800 Subject: [PATCH 17/26] Upgrade uninstall hook after pyenv/pyenv#2432 (#438) --- etc/pyenv.d/uninstall/envs.bash | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/etc/pyenv.d/uninstall/envs.bash b/etc/pyenv.d/uninstall/envs.bash index c3dc5df..5087370 100644 --- a/etc/pyenv.d/uninstall/envs.bash +++ b/etc/pyenv.d/uninstall/envs.bash @@ -2,29 +2,33 @@ 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 + exec pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}" + exit 128 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 + exec pyenv-virtualenv-delete ${FORCE+-f} "${REAL_DEFINITION}" + exit 128 + 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" From 7932bb4cc00e63752f5ff7743aaa72fa72b64f4d Mon Sep 17 00:00:00 2001 From: Joseph Egan Date: Mon, 10 Oct 2022 18:47:19 +0000 Subject: [PATCH 18/26] Stop delete force failing when virtualenv does not exist (#330) --- bin/pyenv-virtualenv-delete | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pyenv-virtualenv-delete b/bin/pyenv-virtualenv-delete index aa21410..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 From 057b9be9d88edbd2afb10fe2aa44473410970032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 10 Oct 2022 21:48:29 +0300 Subject: [PATCH 19/26] fix: relative path to pyenv-realpath.dylib (#378) --- libexec/pyenv-virtualenv-realpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 3c0edf888ef8798bec2824f3f1a721d879bada3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 10 Oct 2022 21:50:28 +0300 Subject: [PATCH 20/26] Spelling fixes (#352) --- CHANGELOG.md | 2 +- bin/pyenv-virtualenv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index b1bb20c..930c211 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -145,7 +145,7 @@ detect_venv() { if [ -x "${prefix}/bin/virtualenv" ]; then HAS_VIRTUALENV=1 fi - # Prefer `python3.x` executable if avaialble (#206, #282) + # Prefer `python3.x` executable if available (#206, #282) local python for python in "python${PYENV_VERSION%.*}" "python${PYENV_VERSION%%.*}" "python"; do if pyenv-exec "${python}" -m venv --help 1>/dev/null 2>&1; then From 9a57cd77113c4bf36fef44dbef6d2cf0b61cdf03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 11 Oct 2022 22:53:34 +0300 Subject: [PATCH 21/26] Clone bats with --depth=1, gitignore it (#351) --- .gitignore | 1 + .travis.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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: From 4054162a1cc1cf3f95baf0cb2c94af47dc5f5341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 12 Oct 2022 07:41:29 +0300 Subject: [PATCH 22/26] Fix errors when `set -u` is set in the user's shell (#350) --- bin/pyenv-virtualenv-init | 6 +++--- test/init.bats | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 1a60c53..a24a785 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -129,7 +129,7 @@ esac if [[ "$shell" != "fish" ]]; then cat < Date: Wed, 12 Oct 2022 21:30:36 +0300 Subject: [PATCH 23/26] Set up Github Actions CI (#440) * Adjust tests: update Pip URLs, update expected output to match newer code * Test library: improve failure message to eliminate the illusion of extra leading space in "actual" output * Use Bats 1.2.0 like Pyenv * Install greadlink for old MacOS * Delete duplicate test --- .github/workflows/tests.yml | 37 +++++++++++++++++++++++++++++++++++++ test/deactivate.bats | 34 ++-------------------------------- test/init.bats | 2 ++ test/pip.bats | 2 +- test/test_helper.bash | 6 ++++-- test/virtualenv.bats | 10 +++++----- 6 files changed, 51 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/tests.yml 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/test/deactivate.bats b/test/deactivate.bats index d0b6dea..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 @@ -54,7 +54,7 @@ EOS export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv" export PYENV_ACTIVATE_SHELL= - PYENV_SHELL="bash" run pyenv-sh-deactivate --quit + PYENV_SHELL="bash" run pyenv-sh-deactivate --quiet assert_success assert_output </dev/null 2>&1; then - unset -f deactivate; -fi; -EOS -} - @test "deactivate virtualenv (with shell activation)" { export PYENV_VIRTUALENV_INIT=1 export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv" diff --git a/test/init.bats b/test/init.bats index ba90b5d..85f2b42 100644 --- a/test/init.bats +++ b/test/init.bats @@ -72,6 +72,8 @@ EOS run pyenv-virtualenv-init - fish assert_success assert_output < Date: Wed, 12 Oct 2022 21:12:21 +0200 Subject: [PATCH 24/26] Enhance documentation about options for `pyenv virtualenv` (#425) Co-authored-by: Ivan Pozdeev --- README.md | 3 +++ bin/pyenv-virtualenv | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7b4244..995bdcd 100644 --- a/README.md +++ b/README.md @@ -99,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-virtualenv b/bin/pyenv-virtualenv index 930c211..27f8d61 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -6,7 +6,11 @@ # pyenv virtualenv --version # pyenv virtualenv --help # -# -f/--force Install even if the version appears to be installed already +# -f/--force Install even if the version appears to be installed already. Skip +# prompting for confirmation +# +# Notable VIRTUALENV_OPTIONS passed to venv-creating executable, if applicable: +# -u/--upgrade Imply --force # PYENV_VIRTUALENV_VERSION="1.1.5" From 633711a0bcc3a2c8e89995ed904d986dc2bb4614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Fern=C3=A1ndez=20Giraldo?= Date: Wed, 12 Oct 2022 13:36:52 -0600 Subject: [PATCH 25/26] Return control to pyenv-uninstall in uninstall/envs.bash (#321) --- etc/pyenv.d/uninstall/envs.bash | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/etc/pyenv.d/uninstall/envs.bash b/etc/pyenv.d/uninstall/envs.bash index 5087370..38bd1d9 100644 --- a/etc/pyenv.d/uninstall/envs.bash +++ b/etc/pyenv.d/uninstall/envs.bash @@ -6,8 +6,7 @@ uninstall_related_virtual_env() { if [ -n "${DEFINITION}" ]; then if [[ "${DEFINITION}" != "${DEFINITION%/envs/*}" ]]; then # Uninstall virtualenv by long name - exec pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}" - exit 128 + pyenv-virtualenv-delete ${FORCE+-f} "${DEFINITION}" else VERSION_NAME="${VERSION_NAME:-${DEFINITION##*/}}" PREFIX="${PREFIX:-${PYENV_ROOT}/versions/${VERSION_NAME}}" @@ -16,8 +15,7 @@ uninstall_related_virtual_env() { 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 + pyenv-virtualenv-delete ${FORCE+-f} "${REAL_DEFINITION}" fi else # Uninstall all virtualenvs inside `envs` directory too From c4de2555b7343c95a3380dece3098eaf3baa4e73 Mon Sep 17 00:00:00 2001 From: Andrew Christianson Date: Thu, 13 Oct 2022 18:37:08 -0700 Subject: [PATCH 26/26] Use realpath of scripts to determine relative locations (#308) Just using paths relative to ${BASH_SOURCE} to access `libexec` fails if the scripts are symlinked to a location, such as when installed with Homebrew, since the `libexec` directory is not linked into `brew --prefix`. Implement a simple version of `realpath` and run `${BASH_SOURCE}` through it. This gets the actual installation directory relative to which `libexec` is located. Co-authored-by: Andrew Christianson --- bin/pyenv-virtualenv-prefix | 16 +++++++++++++++- bin/pyenv-virtualenvs | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bin/pyenv-virtualenv-prefix b/bin/pyenv-virtualenv-prefix index aa71777..bbe5871 100755 --- a/bin/pyenv-virtualenv-prefix +++ b/bin/pyenv-virtualenv-prefix @@ -6,7 +6,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" diff --git a/bin/pyenv-virtualenvs b/bin/pyenv-virtualenvs index f9426bb..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"