diff --git a/README.md b/README.md index 751e040..e5a7088 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,24 @@ the `~/.pyenv/plugins/python-virtualenv` directory. From that directory, you can check out a specific release tag. To update python-virtualenv, run `git pull` to download the latest changes. +### Installing as a standalone program (advanced) + +Installing python-virtualenv as a standalone program will give you access to +the `python-virtualenv` command for precise control over Python version +installation. If you have rbenv installed, you will also be able to +use the `rbenv install` command. + + $ git clone git://github.com/yyuu/python-virtualenv.git + $ cd python-virtualenv + $ ./install.sh + +This will install python-virtualenv into `/usr/local`. If you do not have +write permission to `/usr/local`, you will need to run `sudo +./install.sh` instead. You can install to a different prefix by +setting the `PREFIX` environment variable. + +To update python-virtualenv after it has been installed, run `git pull` in +your cloned copy of the repository, then re-run the install script. ## Usage diff --git a/bin/python-virtualenv b/bin/python-virtualenv index 4aa7d2a..f7c66d4 100755 --- a/bin/python-virtualenv +++ b/bin/python-virtualenv @@ -115,7 +115,9 @@ fi VIRTUALENV_PYTHON_BIN="${VIRTUALENV_PATH}/bin/python" # create virtualenv -"${PYTHON_BIN}" "${PYTHON_VIRTUALENV_ROOT}/libexec/virtualenv.py" "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" +VIRTUALENV="${PYTHON_VIRTUALENV_ROOT}/libexec/python-virtualenv/virtualenv.py" +[ -f "${VIRTUALENV}" ] || VIRTUALENV="${PYTHON_VIRTUALENV_ROOT}/libexec/virtualenv.py" +"${PYTHON_BIN}" "${VIRTUALENV}" "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" # create symlink of `python' bound for actual executable if [ ! -f "$VIRTUALENV_PYTHON_BIN" ]; then diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..2933fcb --- /dev/null +++ b/install.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +if [ -z "${PREFIX}" ]; then + PREFIX="/usr/local" +fi + +BIN_PATH="${PREFIX}/bin" +LIBEXEC_PATH="${PREFIX}/libexec/python-virtualenv" + +mkdir -p "${BIN_PATH}" +mkdir -p "${LIBEXEC_PATH}" + +for file in bin/*; do + cp "${file}" "${BIN_PATH}" +done + +for file in libexec/*; do + cp "${file}" "${LIBEXEC_PATH}" +done + +echo "Installed python-virtualenv at ${PREFIX}"