mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-11 13:03:52 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa9950aa5b | ||
|
|
124645e84c | ||
|
|
ec60d5dfcb | ||
|
|
d96a00ece3 | ||
|
|
20e31ed587 | ||
|
|
32bfce2e41 | ||
|
|
99de2882e3 |
37
README.md
37
README.md
@@ -18,9 +18,13 @@ Installing pyenv-virtualenv as a pyenv plugin will give you access to the
|
||||
$ git clone git://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
|
||||
|
||||
This will install the latest development version of pyenv-virtualenv into
|
||||
the `~/.pyenv/plugins/pyenv-virtualenv` directory. From that directory, you
|
||||
can check out a specific release tag. To update pyenv-virtualenv, run `git
|
||||
pull` to download the latest changes.
|
||||
the `~/.pyenv/plugins/pyenv-virtualenv` directory.
|
||||
**Important note:** If you installed pyenv into a non-standard directory, make sure that you clone this
|
||||
repo into the 'plugins' directory of wherever you installed into.
|
||||
|
||||
From inside that directory you can:
|
||||
- Check out a specific release tag.
|
||||
- Get the latest development release by running `git pull` to download the latest changes.
|
||||
|
||||
### Installing with Homebrew (for OS X users)
|
||||
|
||||
@@ -44,13 +48,13 @@ Or, if you would like to install the latest development release:
|
||||
### Using `pyenv virtualenv` with pyenv
|
||||
|
||||
To create a virtualenv for the Python version use with pyenv, run
|
||||
`pyenv virtualenv` with tha exact name of the version you want to create
|
||||
virtualenv. For example,
|
||||
`pyenv virtualenv`, specifying the Python version you want and the name
|
||||
of the virtualenv directory. For example,
|
||||
|
||||
$ pyenv virtualenv 2.7.5 venv27
|
||||
$ pyenv virtualenv 2.7.6 my-virtual-env-2.7.6
|
||||
|
||||
virtualenvs will be created into a directory of the same name
|
||||
under `~/.pyenv/versions`.
|
||||
will create a virtualenv based on Python 2.7.6
|
||||
under `~/.pyenv/versions` in a folder called `my-virtual-env-2.7.6`.
|
||||
|
||||
|
||||
### Create virtualenv from current version
|
||||
@@ -60,7 +64,7 @@ virtualenv will be created with given name based on current
|
||||
version.
|
||||
|
||||
$ pyenv version
|
||||
3.3.2 (set by /home/yyuu/.pyenv/version)
|
||||
3.3.3 (set by /home/yyuu/.pyenv/version)
|
||||
$ pyenv virtualenv venv33
|
||||
|
||||
|
||||
@@ -70,8 +74,8 @@ version.
|
||||
|
||||
$ pyenv shell venv27
|
||||
$ pyenv virtualenvs
|
||||
* venv27 (created from /home/yyuu/.pyenv/versions/2.7.5)
|
||||
venv33 (created from /home/yyuu/.pyenv/versions/3.3.2)
|
||||
* venv27 (created from /home/yyuu/.pyenv/versions/2.7.6)
|
||||
venv33 (created from /home/yyuu/.pyenv/versions/3.3.3)
|
||||
|
||||
|
||||
### Special environment variables
|
||||
@@ -83,6 +87,8 @@ You can set certain environment variables to control the pyenv-virtualenv.
|
||||
* `VIRTUALENV_VERSION`, if set, forces pyenv-virtualenv to install desired
|
||||
version of virtualenv. If the virtualenv has not been installed,
|
||||
pyenv-virtualenv will try to install the given version of virtualenv.
|
||||
* `EZ_SETUP` and `GET_PIP`, if set and pyvenv is preferred than virtualenv,
|
||||
use `ez_setup.py` and `get_pip.py` at specified location.
|
||||
* `EZ_SETUP_URL` and `GET_PIP_URL`, if set and pyvenv is preferred
|
||||
than virtualenv, download `ez_setup.py` and `get_pip.py` from specified URL.
|
||||
* `SETUPTOOLS_VERSION` and `PIP_VERSION`, if set and pyvenv is preferred
|
||||
@@ -91,6 +97,15 @@ You can set certain environment variables to control the pyenv-virtualenv.
|
||||
|
||||
## Version History
|
||||
|
||||
#### 20140110
|
||||
|
||||
* Support environment variables of `EZ_SETUP` and `GET_PIP`.
|
||||
* Support a short option `-p` of `virtualenv`.
|
||||
|
||||
#### 20131216
|
||||
|
||||
* Use latest release of setuptools and pip if the version not given via environment variables.
|
||||
|
||||
#### 20130622
|
||||
|
||||
* Removed bundled `virtualenv.py` script. Now pyenv-virtualenv installs `virtualenv` package into source version and then use it.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# -f/--force Install even if the version appears to be installed already
|
||||
#
|
||||
|
||||
PYENV_VIRTUALENV_VERSION="20130622"
|
||||
PYENV_VIRTUALENV_VERSION="20140110"
|
||||
|
||||
set -e
|
||||
[ -n "$PYENV_DEBUG" ] && set -x
|
||||
@@ -128,6 +128,44 @@ venv() {
|
||||
fi
|
||||
}
|
||||
|
||||
install_setuptools() {
|
||||
local version="$1"
|
||||
{ if [ "${EZ_SETUP+defined}" ] && [ -f "${EZ_SETUP}" ]; then
|
||||
echo "Installing setuptools from ${EZ_SETUP}..." 1>&2
|
||||
cat "${EZ_SETUP}"
|
||||
else
|
||||
[ -n "${EZ_SETUP_URL}" ] || {
|
||||
if [ -n "${SETUPTOOLS_VERSION}" ]; then
|
||||
EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/raw/${SETUPTOOLS_VERSION}/ez_setup.py"
|
||||
else
|
||||
EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py"
|
||||
fi
|
||||
}
|
||||
echo "Installing setuptools from ${EZ_SETUP_URL}..." 1>&2
|
||||
http get "${EZ_SETUP_URL}"
|
||||
fi
|
||||
} | PYENV_VERSION="${version}" pyenv-exec python
|
||||
}
|
||||
|
||||
install_pip() {
|
||||
local version="$1"
|
||||
{ if [ "${GET_PIP+defined}" ] && [ -f "${GET_PIP}" ]; then
|
||||
echo "Installing pip from ${GET_PIP}..." 1>&2
|
||||
cat "${GET_PIP}"
|
||||
else
|
||||
[ -n "${GET_PIP_URL}" ] || {
|
||||
if [ -n "${PIP_VERSION}" ]; then
|
||||
GET_PIP_URL="https://raw.github.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py"
|
||||
else
|
||||
GET_PIP_URL="https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
|
||||
fi
|
||||
}
|
||||
echo "Installing pip from ${GET_PIP_URL}..." 1>&2
|
||||
http get "${GET_PIP_URL}"
|
||||
fi
|
||||
} | PYENV_VERSION="${version}" pyenv-exec python
|
||||
}
|
||||
|
||||
PYENV_VIRTUALENV_ROOT="$(abs_dirname "$0")/.."
|
||||
if [ -z "${PYENV_VIRTUALENV_CACHE_PATH}" ]; then
|
||||
PYENV_VIRTUALENV_CACHE_PATH="${PYTHON_BUILD_CACHE_PATH:-${PYENV_ROOT}/cache}"
|
||||
@@ -148,6 +186,10 @@ for option in "${OPTIONS[@]}"; do
|
||||
"h" | "help" )
|
||||
usage 0
|
||||
;;
|
||||
"p" )
|
||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--python=${ARGUMENTS[0]}"
|
||||
ARGUMENTS=("${ARGUMENTS[@]:1}") # shift 1
|
||||
;;
|
||||
"q" | "quiet" )
|
||||
QUIET="--quiet"
|
||||
;;
|
||||
@@ -283,28 +325,12 @@ mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
|
||||
cd "${PYENV_VIRTUALENV_CACHE_PATH}"
|
||||
venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" && {
|
||||
if virtualenv_is_pyvenv; then
|
||||
[ -n "${EZ_SETUP_URL}" ] || {
|
||||
if [ -n "${SETUPTOOLS_VERSION}" ]; then
|
||||
EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/raw/${SETUPTOOLS_VERSION}/ez_setup.py"
|
||||
else
|
||||
EZ_SETUP_URL="https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py"
|
||||
fi
|
||||
}
|
||||
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python -c 'import setuptools' 1>/dev/null 2>&1 || {
|
||||
echo "Installing setuptools from ${EZ_SETUP_URL}..." 1>&2
|
||||
http get "${EZ_SETUP_URL}" | PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python
|
||||
install_setuptools "${VIRTUALENV_NAME}" 1>&2
|
||||
}
|
||||
|
||||
[ -n "${GET_PIP_URL}" ] || {
|
||||
if [ -n "${PIP_VERSION}" ]; then
|
||||
GET_PIP_URL="https://raw.github.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py"
|
||||
else
|
||||
GET_PIP_URL="https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
|
||||
fi
|
||||
}
|
||||
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-which pip 1>/dev/null 2>&1 || {
|
||||
echo "Installing pip from ${GET_PIP_URL}..." 1>&2
|
||||
http get "${GET_PIP_URL}" | PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec python
|
||||
install_pip "${VIRTUALENV_NAME}" 1>&2
|
||||
}
|
||||
fi
|
||||
} || STATUS="$?"
|
||||
|
||||
Reference in New Issue
Block a user