Merge pull request #1814 from native-api/rm_script_dir

Remove the "Using script's directory as PYENV_DIR if shim is invoked with a script argument" feature
This commit is contained in:
Anton Petrov 2021-03-09 14:36:12 +03:00 committed by GitHub
commit afb14d2072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 56 deletions

View file

@ -62,24 +62,6 @@ else
fi fi
export PYENV_ROOT export PYENV_ROOT
# Transfer PYENV_FILE_ARG (from shims) into PYENV_DIR.
if [ -z "${PYENV_DIR}" ]; then
if [ -n "${PYENV_FILE_ARG}" ]; then
if [ -L "${PYENV_FILE_ARG}" ]; then
PYENV_DIR="$(abs_dirname "${PYENV_FILE_ARG}")"
else
PYENV_DIR="${PYENV_FILE_ARG%/*}"
fi
export PYENV_DIR
unset PYENV_FILE_ARG
fi
else
[[ $PYENV_DIR == /* ]] || PYENV_DIR="$PWD/$PYENV_DIR"
cd "$PYENV_DIR" 2>/dev/null || abort "cannot change working directory to \`$PYENV_DIR'"
PYENV_DIR="$PWD"
cd "$OLDPWD"
fi
if [ -z "${PYENV_DIR}" ]; then if [ -z "${PYENV_DIR}" ]; then
PYENV_DIR="$PWD" PYENV_DIR="$PWD"
fi fi

View file

@ -68,19 +68,6 @@ set -e
[ -n "\$PYENV_DEBUG" ] && set -x [ -n "\$PYENV_DEBUG" ] && set -x
program="\${0##*/}" program="\${0##*/}"
if [[ "\$program" = "python"* ]]; then
for arg; do
case "\$arg" in
-c* | -- ) break ;;
*/* )
if [ -f "\$arg" ]; then
export PYENV_FILE_ARG="\$arg"
break
fi
;;
esac
done
fi
export PYENV_ROOT="$PYENV_ROOT" export PYENV_ROOT="$PYENV_ROOT"
exec "$(command -v pyenv)" exec "\$program" "\$@" exec "$(command -v pyenv)" exec "\$program" "\$@"

View file

@ -12,28 +12,3 @@ load test_helper
PYENV_VERSION="2.7.10:system" run pyenv-prefix PYENV_VERSION="2.7.10:system" run pyenv-prefix
assert_success "${PYENV_ROOT}/versions/2.7.10:${PYENV_TEST_DIR}" assert_success "${PYENV_ROOT}/versions/2.7.10:${PYENV_TEST_DIR}"
} }
@test "should use dirname of file argument as PYENV_DIR" {
mkdir -p "${PYENV_TEST_DIR}/dir1"
touch "${PYENV_TEST_DIR}/dir1/file.py"
PYENV_FILE_ARG="${PYENV_TEST_DIR}/dir1/file.py" run pyenv echo PYENV_DIR
assert_output "${PYENV_TEST_DIR}/dir1"
}
@test "should follow symlink of file argument (#379, #404)" {
mkdir -p "${PYENV_TEST_DIR}/dir1"
mkdir -p "${PYENV_TEST_DIR}/dir2"
touch "${PYENV_TEST_DIR}/dir1/file.py"
ln -s "${PYENV_TEST_DIR}/dir1/file.py" "${PYENV_TEST_DIR}/dir2/symlink.py"
PYENV_FILE_ARG="${PYENV_TEST_DIR}/dir2/symlink.py" run pyenv echo PYENV_DIR
assert_output "${PYENV_TEST_DIR}/dir1"
}
@test "should handle relative symlinks for file argument (#580)" {
mkdir -p "${PYENV_TEST_DIR}"
cd "${PYENV_TEST_DIR}"
touch file.py
ln -s file.py symlink.py
PYENV_FILE_ARG="symlink.py" run pyenv echo PYENV_DIR
assert_output "${PYENV_TEST_DIR}"
}