You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
817 B

преди 11 години
  1. #!/usr/bin/env bash
  2. # Summary: Detect the file that sets the current pyenv version
  3. set -e
  4. [ -n "$PYENV_DEBUG" ] && set -x
  5. find_local_version_file() {
  6. local root="$1"
  7. while [ -n "$root" ]; do
  8. if [ -e "${root}/.python-version" ]; then
  9. echo "${root}/.python-version"
  10. exit
  11. elif [ -e "${root}/.pyenv-version" ]; then
  12. echo "${root}/.pyenv-version"
  13. exit
  14. fi
  15. root="${root%/*}"
  16. done
  17. }
  18. find_local_version_file "$PYENV_DIR"
  19. [ "$PYENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
  20. global_version_file="${PYENV_ROOT}/version"
  21. if [ -e "$global_version_file" ]; then
  22. echo "$global_version_file"
  23. elif [ -e "${PYENV_ROOT}/global" ]; then
  24. echo "${PYENV_ROOT}/global"
  25. elif [ -e "${PYENV_ROOT}/default" ]; then
  26. echo "${PYENV_ROOT}/default"
  27. else
  28. echo "$global_version_file"
  29. fi