Permalink
Browse files

created new project.

modified rbenv source for Python and renamed to pyenv.
  • Loading branch information...
Yamashita Yuu
Yamashita Yuu committed Aug 31, 2012
0 parents commit 2457419b4acb65b76dd40d55f51b33a4a9e2f1e9
@@ -0,0 +1,4 @@
+/plugins
+/shims
+/version
+/versions
21 LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2011 Sam Stephenson
+Copyright (c) 2012 Yamashita, Yuu
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
152 README.md
@@ -0,0 +1,152 @@
+# Simple Python Version Management: pyenv
+
+pyenv lets you easily switch between multiple versions of Python. It's
+simple, unobtrusive, and follows the UNIX tradition of single-purpose
+tools that do one thing well.
+
+This project was forked from [rbenv](https://github.com/sstephenson/rbenv) and.
+[ruby-build](https://github.com/sstephenson/ruby-build) and modified for Python.
+
+### pyenv _does…_
+
+* Let you **change the global Python version** on a per-user basis.
+* Provide support for **per-project Python versions**.
+* Allow you to **override the Python version** with an environment
+ variable.
+
+## Table of Contents
+
+ * [1 How It Works](#section_1)
+ * [2 Installation](#section_2)
+ * [2.1 Basic GitHub Checkout](#section_2.1)
+ * [2.1.1 Upgrading](#section_2.1.1)
+ * [3 Usage](#section_3)
+ * [4 Development](#section_4)
+ * [4.1 Version History](#section_4.1)
+ * [4.2 License](#section_4.2)
+
+## <a name="section_1"></a> 1 How It Works
+
+pyenv operates on the per-user directory `~/.pyenv`. Version names in
+pyenv correspond to subdirectories of `~/.pyenv/versions`. For
+example, you might have `~/.pyenv/versions/2.7.3` and
+`~/.pyenv/versions/2.7.3`.
+
+Each version is a working tree with its own binaries, like
+`~/.pyenv/versions/2.7.3/bin/python2.7` and
+`~/.pyenv/versions/3.2.3/bin/python3.2`. pyenv makes _shim binaries_
+for every such binary across all installed versions of Python.
+
+These shims are simple wrapper scripts that live in `~/.pyenv/shims`
+and detect which Python version you want to use. They insert the
+directory for the selected version at the beginning of your `$PATH`
+and then execute the corresponding binary.
+
+Because of the simplicity of the shim approach, all you need to use
+pyenv is `~/.pyenv/shims` in your `$PATH`.
+
+## <a name="section_2"></a> 2 Installation
+
+### <a name="section_2.1"></a> 2.1 Basic GitHub Checkout
+
+This will get you going with the latest version of pyenv and make it
+easy to fork and contribute any changes back upstream.
+
+1. Check out pyenv into `~/.pyenv`.
+
+ $ cd
+ $ git clone git://github.com/yyuu/pyenv.git .pyenv
+
+2. Add `~/.pyenv/bin` to your `$PATH` for access to the `pyenv`
+ command-line utility.
+
+ $ echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bash_profile
+
+ **Zsh note**: Modify your `~/.zshenv` file instead of `~/.bash_profile`.
+
+3. Add pyenv init to your shell to enable shims and autocompletion.
+
+ $ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
+
+ **Zsh note**: Modify your `~/.zshenv` file instead of `~/.bash_profile`.
+
+4. Restart your shell so the path changes take effect. You can now
+ begin using pyenv.
+
+ $ exec $SHELL
+
+5. Install Python versions into `~/.pyenv/versions`. For example, to
+ install Python 2.7.3, download and unpack the source, then run:
+
+ $ pyenv install 2.7.3
+
+6. Rebuild the shim binaries. You should do this any time you install
+ a new Python binary (for example, when installing a new Python version,
+ or when installing a gem that provides a binary).
+
+ $ pyenv rehash
+
+#### <a name="section_2.1.1"></a> 2.1.1 Upgrading
+
+If you've installed pyenv using the instructions above, you can
+upgrade your installation at any time using git.
+
+To upgrade to the latest development version of pyenv, use `git pull`:
+
+ $ cd ~/.pyenv
+ $ git pull
+
+To upgrade to a specific release of pyenv, check out the corresponding
+tag:
+
+ $ cd ~/.pyenv
+ $ git fetch
+ $ git tag
+ v0.1.0
+ v0.1.1
+ v0.1.2
+ v0.2.0
+ $ git checkout v0.2.0
+
+## <a name="section_3"></a> 3 Usage
+
+## <a name="section_4"></a> 4 Development
+
+The pyenv source code is [hosted on
+GitHub](https://github.com/yyuu/pyenv). It's clean, modular,
+and easy to understand, even if you're not a shell hacker.
+
+Please feel free to submit pull requests and file bugs on the [issue
+tracker](https://github.com/yyuu/pyenv/issues).
+
+### <a name="section_4.1"></a> 4.1 Version History
+
+**0.1.0** (August 31, 2012)
+
+* Initial public release.
+
+### <a name="section_4.2"></a> 4.2 License
+
+(The MIT license)
+
+Copyright (c) 2011 Sam Stephenson
+Copyright (c) 2012 Yamashita, Yuu
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+#
+# `python-local-exec` is a drop-in replacement for the standard Python
+# shebang line:
+#
+# #!/usr/bin/env python-local-exec
+#
+# Use it for scripts inside a project with an `.pyenv-version`
+# file. When you run the scripts, they'll use the project-specified
+# Python version, regardless of what directory they're run from. Useful
+# for e.g. running project tasks in cron scripts without needing to
+# `cd` into the project first.
+
+set -e
+export PYENV_DIR="${1%/*}"
+exec python "$@"
@@ -0,0 +1,14 @@
+_pyenv() {
+ COMPREPLY=()
+ local word="${COMP_WORDS[COMP_CWORD]}"
+
+ if [ "$COMP_CWORD" -eq 1 ]; then
+ COMPREPLY=( $(compgen -W "$(pyenv commands)" -- "$word") )
+ else
+ local command="${COMP_WORDS[1]}"
+ local completions="$(pyenv completions "$command")"
+ COMPREPLY=( $(compgen -W "$completions" -- "$word") )
+ fi
+}
+
+complete -F _pyenv pyenv
@@ -0,0 +1,19 @@
+if [[ ! -o interactive ]]; then
+ return
+fi
+
+compctl -K _pyenv pyenv
+
+_pyenv() {
+ local word words completions
+ read -cA words
+ word="${words[2]}"
+
+ if [ "${#words}" -eq 2 ]; then
+ completions="$(pyenv commands)"
+ else
+ completions="$(pyenv completions "${word}")"
+ fi
+
+ reply=("${(ps:\n:)completions}")
+}
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$PYENV_DEBUG" ] && set -x
+
+resolve_link() {
+ $(type -p greadlink readlink | head -1) "$1"
+}
+
+abs_dirname() {
+ local cwd="$(pwd)"
+ local path="$1"
+
+ while [ -n "$path" ]; do
+ cd "${path%/*}"
+ local name="${path##*/}"
+ path="$(resolve_link "$name" || true)"
+ done
+
+ pwd
+ cd "$cwd"
+}
+
+if [ -z "${PYENV_ROOT}" ]; then
+ PYENV_ROOT="${HOME}/.pyenv"
+else
+ PYENV_ROOT="${PYENV_ROOT%/}"
+fi
+export PYENV_ROOT
+
+if [ -z "${PYENV_DIR}" ]; then
+ PYENV_DIR="$(pwd)"
+else
+ cd "$PYENV_DIR" 2>/dev/null || {
+ echo "pyenv: cannot change working directory to \`$PYENV_DIR'"
+ exit 1
+ } >&2
+ PYENV_DIR="$(pwd)"
+ cd "$OLDPWD"
+fi
+export PYENV_DIR
+
+
+shopt -s nullglob
+
+bin_path="$(abs_dirname "$0")"
+for plugin_bin in "${PYENV_ROOT}/plugins/"*/bin; do
+ bin_path="${bin_path}:${plugin_bin}"
+done
+export PATH="${bin_path}:${PATH}"
+
+hook_path="${PYENV_HOOK_PATH}:${PYENV_ROOT}/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks"
+for plugin_hook in "${PYENV_ROOT}/plugins/"*/etc/pyenv.d; do
+ hook_path="${hook_path}:${plugin_hook}"
+done
+export PYENV_HOOK_PATH="$hook_path"
+
+shopt -u nullglob
+
+
+command="$1"
+case "$command" in
+"" | "-h" | "--help" )
+ echo -e "pyenv 0.1.0\n$(pyenv-help)" >&2
+ ;;
+* )
+ command_path="$(command -v "pyenv-$command" || true)"
+ if [ -z "$command_path" ]; then
+ echo "pyenv: no such command \`$command'" >&2
+ exit 1
+ fi
+
+ shift 1
+ exec "$command_path" "$@"
+ ;;
+esac
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$PYENV_DEBUG" ] && set -x
+
+# Provide pyenv completions
+if [ "$1" = "--complete" ]; then
+ echo --sh
+ echo --no-sh
+ exit
+fi
+
+if [ "$1" = "--sh" ]; then
+ sh=1
+ shift
+elif [ "$1" = "--no-sh" ]; then
+ nosh=1
+ shift
+fi
+
+shopt -s nullglob
+
+{ for path in ${PATH//:/$'\n'}; do
+ for command in "${path}/pyenv-"*; do
+ command="${command##*pyenv-}"
+ if [ -n "$sh" ]; then
+ if [ ${command:0:3} = "sh-" ]; then
+ echo ${command##sh-}
+ fi
+ elif [ -n "$nosh" ]; then
+ if [ ${command:0:3} != "sh-" ]; then
+ echo ${command##sh-}
+ fi
+ else
+ echo ${command##sh-}
+ fi
+ done
+ done
+} | sort | uniq
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$PYENV_DEBUG" ] && set -x
+
+COMMAND="$1"
+if [ -z "$COMMAND" ]; then
+ echo "usage: pyenv completions COMMAND [arg1 arg2...]" >&2
+ exit 1
+fi
+
+COMMAND_PATH="$(command -v "pyenv-$COMMAND" || command -v "pyenv-sh-$COMMAND")"
+if grep -i "^# provide pyenv completions" "$COMMAND_PATH" >/dev/null; then
+ shift
+ exec "$COMMAND_PATH" --complete "$@"
+fi
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$PYENV_DEBUG" ] && set -x
+
+# Provide pyenv completions
+if [ "$1" = "--complete" ]; then
+ exec pyenv shims --short
+fi
+
+PYENV_COMMAND="$1"
+if [ -z "$PYENV_COMMAND" ]; then
+ echo "usage: pyenv exec COMMAND [arg1 arg2...]" >&2
+ exit 1
+fi
+
+PYENV_COMMAND_PATH="$(pyenv-which "$PYENV_COMMAND")"
+PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}"
+
+for script in $(pyenv-hooks exec); do
+ source "$script"
+done
+
+shift 1
+export PATH="${PYENV_BIN_PATH}:${PATH}"
+exec -a "$PYENV_COMMAND" "$PYENV_COMMAND_PATH" "$@"
Oops, something went wrong.

0 comments on commit 2457419

Please sign in to comment.