Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

48 lignes
1.4 KiB

il y a 10 ans
  1. #!/usr/bin/env bash
  2. #
  3. # Summary: Set or show the local application-specific Python version
  4. #
  5. # Usage: pyenv local <version>
  6. # pyenv local --unset
  7. #
  8. # Sets the local application-specific Python version by writing the
  9. # version name to a file named `.python-version'.
  10. #
  11. # When you run a Python command, pyenv will look for a `.python-version'
  12. # file in the current directory and each parent directory. If no such
  13. # file is found in the tree, pyenv will use the global Python version
  14. # specified with `pyenv global'. A version specified with the
  15. # `PYENV_VERSION' environment variable takes precedence over local
  16. # and global versions.
  17. #
  18. # <version> should be a string matching a Python version known to pyenv.
  19. # The special version string `system' will use your default system Python.
  20. # Run `pyenv versions' for a list of available Python versions.
  21. set -e
  22. [ -n "$PYENV_DEBUG" ] && set -x
  23. # Provide pyenv completions
  24. if [ "$1" = "--complete" ]; then
  25. echo --unset
  26. echo system
  27. exec pyenv-versions --bare
  28. fi
  29. versions=("$@")
  30. if [ "$versions" = "--unset" ]; then
  31. rm -f .python-version
  32. elif [ -n "$versions" ]; then
  33. pyenv-version-file-write .python-version "${versions[@]}"
  34. else
  35. if version_file="$(pyenv-version-file "$PWD")"; then
  36. IFS=: versions=($(pyenv-version-file-read "$version_file"))
  37. for version in "${versions[@]}"; do
  38. echo "$version"
  39. done
  40. else
  41. echo "pyenv: no local version configured for this directory" >&2
  42. exit 1
  43. fi
  44. fi