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.

46 lines
1.0 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. #!/usr/bin/env bash
  2. # Summary: Show the current Python version
  3. set -e
  4. [ -n "$PYENV_DEBUG" ] && set -x
  5. if [ -z "$PYENV_VERSION" ]; then
  6. PYENV_VERSION_FILE="$(pyenv-version-file)"
  7. PYENV_VERSION="$(pyenv-version-file-read "$PYENV_VERSION_FILE" || true)"
  8. fi
  9. if [ -z "$PYENV_VERSION" ] || [ "$PYENV_VERSION" = "system" ]; then
  10. echo "system"
  11. exit
  12. fi
  13. version_exists() {
  14. local version="$1"
  15. [ -d "${PYENV_ROOT}/versions/${version}" ]
  16. }
  17. versions=()
  18. OLDIFS="$IFS"
  19. { IFS=:
  20. any_not_installed=0
  21. for version in ${PYENV_VERSION}; do
  22. if version_exists "$version" || [ "$version" = "system" ]; then
  23. versions=("${versions[@]}" "${version}")
  24. elif version_exists "${version#python-}"; then
  25. versions=("${versions[@]}" "${version#python-}")
  26. else
  27. echo "pyenv: version \`$version' is not installed (set by $(pyenv-version-origin))" >&2
  28. any_not_installed=1
  29. fi
  30. done
  31. }
  32. IFS="$OLDIFS"
  33. OLDIFS="$IFS"
  34. { IFS=:
  35. echo "${versions[*]}"
  36. }
  37. IFS="$OLDIFS"
  38. if [ "$any_not_installed" = 1 ]; then
  39. exit 1
  40. fi