From dfd165506933d2f81e3b5a0eb6528f06ce653d01 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Fri, 6 Nov 2015 04:16:14 +0000 Subject: [PATCH 1/4] add a script to hook `source activate` for Anaconda/Miniconda (#103) --- bin/pyenv-virtualenv-init | 30 ++++++++++++++++++++++++++++-- install.sh | 2 ++ shims/activate | 7 +++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 shims/activate diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 080f54b..db15aa3 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -9,6 +9,26 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x +resolve_link() { + $(type -p greadlink readlink | head -1) "$1" +} + +abs_dirname() { + local cwd="$(pwd)" + local path="$1" + + while [ -n "$path" ]; do + cd "${path%/*}" + local name="${path##*/}" + path="$(resolve_link "$name" || true)" + done + + pwd + cd "$cwd" +} + +PYENV_VIRTUALENV_INSTALL_PREFIX="$(dirname "$(abs_dirname "$0")")" + print="" for args in "$@" do @@ -65,10 +85,16 @@ fi case "$shell" in fish ) - echo "setenv PYENV_VIRTUALENV_INIT 1;" + cat <&2 + false +fi From ad2ada84ab9f28ccda93b16e50af43ab46253bb8 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Fri, 6 Nov 2015 06:28:22 +0000 Subject: [PATCH 2/4] fix broken tests --- test/init.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/init.bats b/test/init.bats index b280fdb..0cd7e09 100644 --- a/test/init.bats +++ b/test/init.bats @@ -46,9 +46,11 @@ load test_helper } @test "outputs bash-specific syntax" { + export PYENV_VIRTUALENV_ROOT="${TMP}/pyenv/plugins/pyenv-virtualenv" run pyenv-virtualenv-init - bash assert_success assert_output </dev/null; or true) @@ -112,9 +116,11 @@ EOS } @test "outputs zsh-specific syntax" { + export PYENV_VIRTUALENV_ROOT="${TMP}/pyenv/plugins/pyenv-virtualenv" run pyenv-virtualenv-init - zsh assert_success assert_output < Date: Fri, 6 Nov 2015 06:31:19 +0000 Subject: [PATCH 3/4] add shim for `deactivate` --- shims/deactivate | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 shims/deactivate diff --git a/shims/deactivate b/shims/deactivate new file mode 100755 index 0000000..3a39302 --- /dev/null +++ b/shims/deactivate @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [[ "$0" != "${BASH_SOURCE}" ]]; then + eval "$(pyenv sh-deactivate --verbose "$@" || true)" +else + echo "pyenv-virtualenv: deactivate must be sourced. Run 'source deactivate' instead of 'deactivate'" 1>&2 + false +fi From c54d48013592a31c119ceaf1ffbf3a2c88330c87 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Fri, 6 Nov 2015 06:52:40 +0000 Subject: [PATCH 4/4] fix broken installer script --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index b4975a2..c5bd24a 100755 --- a/install.sh +++ b/install.sh @@ -15,6 +15,7 @@ BIN_PATH="${PREFIX}/bin" SHIMS_PATH="${PREFIX}/shims" mkdir -p "$BIN_PATH" +mkdir -p "$SHIMS_PATH" install -p bin/* "$BIN_PATH" install -p shims/* "$SHIMS_PATH"