No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

50 líneas
1.2 KiB

  1. #!/usr/bin/env bash
  2. #
  3. # Summary: Set or show the shell-specific Python version
  4. #
  5. # Usage: pyenv shell <version>
  6. # pyenv shell --unset
  7. #
  8. # Sets a shell-specific Python version by setting the `PYENV_VERSION'
  9. # environment variable in your shell. This version overrides local
  10. # application-specific versions and the global version.
  11. #
  12. # <version> should be a string matching a Python version known to pyenv.
  13. # The special version string `system' will use your default system Python.
  14. # Run `pyenv versions' for a list of available Python versions.
  15. set -e
  16. [ -n "$PYENV_DEBUG" ] && set -x
  17. # Provide pyenv completions
  18. if [ "$1" = "--complete" ]; then
  19. echo --unset
  20. echo system
  21. exec pyenv-versions --bare
  22. fi
  23. versions=("$@")
  24. if [ -z "$versions" ]; then
  25. if [ -z "$PYENV_VERSION" ]; then
  26. echo "pyenv: no shell-specific version configured" >&2
  27. exit 1
  28. else
  29. echo "echo \"\$PYENV_VERSION\""
  30. exit
  31. fi
  32. fi
  33. if [ "$versions" = "--unset" ]; then
  34. echo "unset PYENV_VERSION"
  35. exit
  36. fi
  37. # Make sure the specified version is installed.
  38. if pyenv-prefix "${versions[@]}" >/dev/null; then
  39. IFS=: PYENV_VERSION="${versions[*]}"
  40. echo "export PYENV_VERSION=\"${PYENV_VERSION}\""
  41. else
  42. echo "return 1"
  43. exit 1
  44. fi