1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-13 13:53:53 -05:00

add support for .python-version file to store local python version

This commit is contained in:
Yamashita Yuu
2013-01-18 17:55:46 +09:00
parent da06998457
commit 684f7b7f21
2 changed files with 26 additions and 12 deletions

View File

@@ -3,14 +3,22 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
root="$PYENV_DIR"
while [ -n "$root" ]; do
if [ -e "${root}/.pyenv-version" ]; then
echo "${root}/.pyenv-version"
exit
fi
root="${root%/*}"
done
find_local_version_file() {
local root="$1"
while [ -n "$root" ]; do
if [ -e "${root}/.python-version" ]; then
echo "${root}/.python-version"
exit
elif [ -e "${root}/.pyenv-version" ]; then
echo "${root}/.pyenv-version"
exit
fi
root="${root%/*}"
done
}
find_local_version_file "$PYENV_DIR"
[ "$PYENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
global_version_file="${PYENV_ROOT}/version"