Parcourir la source

Attempt to apply equivalent functionalities as rbenv/rbenv#1428

yy-no-realpath
Yamashita, Yuu il y a 2 ans
Parent
révision
c743da4a03
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: EF1B6D80FB708C08
3 fichiers modifiés avec 10 ajouts et 104 suppressions
  1. +2
    -36
      libexec/pyenv
  2. +1
    -32
      libexec/pyenv-hooks
  3. +7
    -36
      libexec/pyenv-versions

+ 2
- 36
libexec/pyenv Voir le fichier

@ -20,41 +20,6 @@ abort() {
exit 1
}
if enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
abs_dirname() {
local path
path="$(realpath "$1")"
echo "${path%/*}"
}
else
[ -z "$PYENV_NATIVE_EXT" ] || abort "failed to load \`realpath' builtin"
READLINK=$(type -P greadlink readlink | head -1)
[ -n "$READLINK" ] || abort "cannot find readlink - are you missing GNU coreutils?"
resolve_link() {
$READLINK "$1"
}
abs_dirname() {
local path="$1"
# Use a subshell to avoid changing the current path
(
while [ -n "$path" ]; do
cd_path="${path%/*}"
if [[ "$cd_path" != "$path" ]]; then
cd "$cd_path"
fi
name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
echo "$PWD"
)
}
fi
if [ -z "${PYENV_ROOT}" ]; then
PYENV_ROOT="${HOME}/.pyenv"
else
@ -76,7 +41,8 @@ export PYENV_DIR
shopt -s nullglob
bin_path="$(abs_dirname "$0")"
pyenv_bin="${BASH_SOURCE:-$0}"
bin_path="$(cd "${pyenv_bin%/*}"/../libexec && pwd -P)"
for plugin_bin in "${bin_path%/*}"/plugins/*/bin; do
PATH="${plugin_bin}:${PATH}"
done

+ 1
- 32
libexec/pyenv-hooks Voir le fichier

@ -21,43 +21,12 @@ if [ -z "$PYENV_COMMAND" ]; then
exit 1
fi
if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; then
if [ -n "$PYENV_NATIVE_EXT" ]; then
echo "pyenv: failed to load \`realpath' builtin" >&2
exit 1
fi
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 "$1"
}
realpath() {
local path="$1"
local name
# Use a subshell to avoid changing the current path
(
while [ -n "$path" ]; do
name="${path##*/}"
[ "$name" = "$path" ] || cd "${path%/*}"
path="$(resolve_link "$name" || true)"
done
echo "${PWD}/$name"
)
}
fi
IFS=: hook_paths=($PYENV_HOOK_PATH)
shopt -s nullglob
for path in "${hook_paths[@]}"; do
for script in "$path/$PYENV_COMMAND"/*.bash; do
realpath "$script"
echo "$script"
done
done
shopt -u nullglob

+ 7
- 36
libexec/pyenv-versions Voir le fichier

@ -25,43 +25,14 @@ for arg; do
esac
done
versions_dir="${PYENV_ROOT}/versions"
if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; then
if [ -n "$PYENV_NATIVE_EXT" ]; then
echo "pyenv: failed to load \`realpath' builtin" >&2
exit 1
fi
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 "$1"
}
realpath() {
local path="$1"
local name
# Use a subshell to avoid changing the current path
(
while [ -n "$path" ]; do
name="${path##*/}"
[ "$name" = "$path" ] || cd "${path%/*}"
path="$(resolve_link "$name" || true)"
done
echo "${PWD}/$name"
)
}
fi
canonicalize_dir() {
{ cd "$1" && pwd -P
} 2>/dev/null || echo "$1"
}
versions_dir="${PYENV_ROOT}/versions"
if [ -d "$versions_dir" ]; then
versions_dir="$(realpath "$versions_dir")"
versions_dir="$(canonicalize_dir "$versions_dir")"
fi
if ((${BASH_VERSINFO[0]} > 3)); then
@ -138,7 +109,7 @@ fi
for path in "${versions_dir_entries[@]}"; do
if [ -d "$path" ]; then
if [ -n "$skip_aliases" ] && [ -L "$path" ]; then
target="$(realpath "$path")"
target="$(canonicalize_dir "$path")"
[ "${target%/*}" != "$versions_dir" ] || continue
[ "${target%/*/envs/*}" != "$versions_dir" ] || continue
fi

Chargement…
Annuler
Enregistrer