mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Preparing for renaming project; s/python-virtualenv/pyenv-virtualenv/g
This commit is contained in:
37
README.md
37
README.md
@@ -1,45 +1,26 @@
|
|||||||
# python-virtualenv
|
# pyenv-virtualenv
|
||||||
|
|
||||||
python-virtualenv is a [pyenv](https://github.com/yyuu/pyenv) plugin
|
pyenv-virtualenv is a [pyenv](https://github.com/yyuu/pyenv) plugin
|
||||||
that provides an `pyenv virtualenv` command to create virtualenv for Python
|
that provides an `pyenv virtualenv` command to create virtualenv for Python
|
||||||
on UNIX-like systems.
|
on UNIX-like systems.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Installing as a pyenv plugin (recommended)
|
### Installing as a pyenv plugin
|
||||||
|
|
||||||
Installing python-virtualenv as a pyenv plugin will give you access to the
|
Installing pyenv-virtualenv as a pyenv plugin will give you access to the
|
||||||
`pyenv virtualenv` command.
|
`pyenv virtualenv` command.
|
||||||
|
|
||||||
$ mkdir -p ~/.pyenv/plugins
|
$ mkdir -p ~/.pyenv/plugins
|
||||||
$ cd ~/.pyenv/plugins
|
$ cd ~/.pyenv/plugins
|
||||||
$ git clone git://github.com/yyuu/python-virtualenv.git
|
$ git clone git://github.com/yyuu/python-virtualenv.git
|
||||||
|
|
||||||
This will install the latest development version of python-virtualenv into
|
This will install the latest development version of pyenv-virtualenv into
|
||||||
the `~/.pyenv/plugins/python-virtualenv` directory. From that directory, you
|
the `~/.pyenv/plugins/python-virtualenv` directory. From that directory, you
|
||||||
can check out a specific release tag. To update python-virtualenv, run `git
|
can check out a specific release tag. To update pyenv-virtualenv, run `git
|
||||||
pull` to download the latest changes.
|
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
|
## Usage
|
||||||
|
|
||||||
### Using `pyenv virtualenv` with pyenv
|
### Using `pyenv virtualenv` with pyenv
|
||||||
@@ -56,6 +37,12 @@ under `~/.pyenv/versions`.
|
|||||||
|
|
||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
|
#### 2013XXYY
|
||||||
|
|
||||||
|
* Preparing for renaming project; `s/python-virtualenv/pyenv-virtualenv/g`
|
||||||
|
* The `pyenv-virtualenv` script is not depending on `python-virtualenv` now.
|
||||||
|
`python-virtualenv` will left for compatibility and not continue for next release.
|
||||||
|
|
||||||
#### 20130218
|
#### 20130218
|
||||||
|
|
||||||
* Add pyenv 0.2.x (rbenv 0.4.x) style help messages.
|
* Add pyenv 0.2.x (rbenv 0.4.x) style help messages.
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Summary: Create a Python virtualenv using the python-virtualenv plugin
|
# Summary: Create a Python virtualenv using the pyenv-virtualenv plugin
|
||||||
#
|
#
|
||||||
# Usage: pyenv virtualenv [-v|--verbose] [VIRTUALENV_OPTIONS] <version> <virtualenv-name>
|
# Usage: pyenv virtualenv [-v|--verbose] [VIRTUALENV_OPTIONS] <version> <virtualenv-name>
|
||||||
#
|
#
|
||||||
# -v/--verbose Verbose mode: print compilation status to stdout
|
# -v/--verbose Verbose mode: print compilation status to stdout
|
||||||
#
|
#
|
||||||
|
|
||||||
|
PYENV_VIRTUALENV_VERSION="20130218"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
@@ -18,8 +21,51 @@ if [ -z "$PYENV_ROOT" ]; then
|
|||||||
PYENV_ROOT="${HOME}/.pyenv"
|
PYENV_ROOT="${HOME}/.pyenv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load shared library functions
|
# Define library functions
|
||||||
eval "$(python-virtualenv --lib)"
|
parse_options() {
|
||||||
|
OPTIONS=()
|
||||||
|
ARGUMENTS=()
|
||||||
|
local arg option index
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ "${arg:0:1}" = "-" ]; then
|
||||||
|
if [ "${arg:1:1}" = "-" ]; then
|
||||||
|
OPTIONS[${#OPTIONS[*]}]="${arg:2}"
|
||||||
|
else
|
||||||
|
index=1
|
||||||
|
while option="${arg:$index:1}"; do
|
||||||
|
[ -n "$option" ] || break
|
||||||
|
OPTIONS[${#OPTIONS[*]}]="$option"
|
||||||
|
index=$(($index+1))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ARGUMENTS[${#ARGUMENTS[*]}]="$arg"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
version() {
|
||||||
|
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION}"
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
# We can remove the sed fallback once pyenv 0.2.0 is widely available.
|
# We can remove the sed fallback once pyenv 0.2.0 is widely available.
|
||||||
@@ -28,7 +74,7 @@ usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unset VERBOSE
|
unset VERBOSE
|
||||||
|
PYENV_VIRTUALENV_ROOT="$(abs_dirname "$0")/.."
|
||||||
VIRTUALENV_OPTIONS=()
|
VIRTUALENV_OPTIONS=()
|
||||||
|
|
||||||
parse_options "$@"
|
parse_options "$@"
|
||||||
@@ -41,7 +87,8 @@ for option in "${OPTIONS[@]}"; do
|
|||||||
VERBOSE="-v"
|
VERBOSE="-v"
|
||||||
;;
|
;;
|
||||||
"version" )
|
"version" )
|
||||||
exec python-virtualenv --version
|
version
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--$option"
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--$option"
|
||||||
@@ -82,5 +129,20 @@ fi
|
|||||||
VIRTUALENV_NAME="${ARGUMENTS[1]##*/}"
|
VIRTUALENV_NAME="${ARGUMENTS[1]##*/}"
|
||||||
VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
|
VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
|
||||||
|
|
||||||
python-virtualenv $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "$PYTHON_BIN" "$VIRTUALENV_PATH"
|
# create virtualenv
|
||||||
pyenv rehash
|
VIRTUALENV="${PYENV_VIRTUALENV_ROOT}/libexec/pyenv-virtualenv/virtualenv.py"
|
||||||
|
[ -f "${VIRTUALENV}" ] || VIRTUALENV="${PYENV_VIRTUALENV_ROOT}/python-libexec/virtualenv.py" # backward compatibility before v20130218
|
||||||
|
[ -f "${VIRTUALENV}" ] || VIRTUALENV="${PYENV_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
|
||||||
|
if [ -f "${VIRTUALENV_PATH}/bin/$(basename "${PYTHON_BIN}")" ]; then
|
||||||
|
{
|
||||||
|
cd ${VIRTUALENV_PATH}/bin
|
||||||
|
ln -fs "$(basename "${PYTHON_BIN}")" python
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
pyenv-rehash
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ if [ -z "${PREFIX}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
BIN_PATH="${PREFIX}/bin"
|
BIN_PATH="${PREFIX}/bin"
|
||||||
LIBEXEC_PATH="${PREFIX}/libexec/python-virtualenv"
|
LIBEXEC_PATH="${PREFIX}/libexec/pyenv-virtualenv"
|
||||||
|
|
||||||
mkdir -p "${BIN_PATH}"
|
mkdir -p "${BIN_PATH}"
|
||||||
mkdir -p "${LIBEXEC_PATH}"
|
mkdir -p "${LIBEXEC_PATH}"
|
||||||
@@ -20,4 +20,4 @@ for file in libexec/*; do
|
|||||||
cp "${file}" "${LIBEXEC_PATH}"
|
cp "${file}" "${LIBEXEC_PATH}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Installed python-virtualenv at ${PREFIX}"
|
echo "Installed pyenv-virtualenv at ${PREFIX}"
|
||||||
|
|||||||
Reference in New Issue
Block a user