19 Commits

Author SHA1 Message Date
Yamashita Yuu
78af7ec9d4 release v20130507 2013-05-07 19:55:31 +09:00
Yamashita Yuu
5b357d2862 display virtualenv's help message on '--help' 2013-05-01 13:07:49 +09:00
Yamashita Yuu
5baa5084dc don't capture '-v' option in $VERBOSE to pass it to virtualenv 2013-05-01 13:05:32 +09:00
Yamashita Yuu
0f8477fcf5 store distribute/setuptools archive in $PYTHON_BUILD_CACHE_PATH to reuse
them between invocations.
2013-04-30 19:55:49 +09:00
Yamashita Yuu
aec759a0e0 ignore error on checking virtualenv version 2013-04-26 13:03:35 +09:00
Yamashita Yuu
15608701ae show virtualenv version in pyenv virtualenv --version 2013-04-25 22:10:29 +09:00
Yamashita Yuu
d927b2e137 update virtualenv version (1.8.4 -> 1.9.1) 2013-04-25 21:45:44 +09:00
Yamashita Yuu
ebeb3dcb71 fix wrong path for libexec 2013-03-27 15:15:44 +09:00
Yamashita Yuu
8b1ae9f19a update README. add note about pyenv-virtualenvwrapper. 2013-03-22 15:38:08 +09:00
Yamashita Yuu
003ea01b97 release v20130307 2013-03-07 13:12:17 +09:00
Yamashita Yuu
1a2d06bc05 update copyright 2013-02-23 19:09:49 +09:00
Yamashita Yuu
5ed1988b34 update README 2013-02-23 16:46:09 +09:00
Yamashita Yuu
c65e8b266b update README 2013-02-20 18:43:07 +09:00
Yamashita Yuu
6ee4bf1e5c Update virtualenv version; 1.8.2 -> 1.8.4 2013-02-18 13:16:10 +09:00
Yamashita Yuu
2910f87cb6 Preparing for renaming project; s/python-virtualenv/pyenv-virtualenv/g 2013-02-18 13:14:42 +09:00
Yamashita Yuu
9651cfe63d release 20130218 2013-02-18 12:42:21 +09:00
Yamashita Yuu
317fcdbfe7 add rbenv 0.4.x style documentation 2013-01-31 12:23:17 +09:00
Yamashita Yuu
fce66ebba7 s/an/a/g 2012-11-06 13:21:21 +09:00
Yamashita Yuu
2551913d75 fix broken markup in README 2012-11-02 22:03:01 +09:00
6 changed files with 612 additions and 439 deletions

View File

@@ -1,5 +1,4 @@
Copyright (c) 2012 Yamashita, Yuu Copyright (c) 2013 Yamashita, Yuu
Copyright (c) 2011 Sam Stephenson
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@@ -1,45 +1,29 @@
# python-virtualenv # pyenv-virtualenv (a.k.a. [python-virtualenv](https://github.com/yyuu/python-virtualenv))
python-virtualenv is an [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.
(NOTICE: If you are an existing user of [virtualenvwrapper](http://pypi.python.org/pypi/virtualenvwrapper)
and you love it, [pyenv-virtualenvwrapper](https://github.com/yyuu/pyenv-virtualenvwrapper) may help you
to manage your virtualenvs.)
## Installation ## Installation
### Installing as an pyenv plugin (recommended) ### Installing as a pyenv plugin
Installing python-virtualenv as an 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/pyenv-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/pyenv-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 +40,22 @@ under `~/.pyenv/versions`.
## Version History ## Version History
#### 20130507
* Display virtualenv information in `--help` and `--version`
* Update virtualenv version; 1.8.4 -> 1.9.1
#### 20130307
* Rename the 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 will not continue for future releases.
* Update virtualenv version; 1.8.2 -> 1.8.4
#### 20130218
* Add pyenv 0.2.x (rbenv 0.4.x) style help messages.
#### 20121023 #### 20121023
* Create virtualenv with exact name of python executables. * Create virtualenv with exact name of python executables.
@@ -71,8 +71,7 @@ under `~/.pyenv/versions`.
(The MIT License) (The MIT License)
Copyright (c) 2012 Yamashita, Yuu * Copyright (c) 2013 Yamashita, Yuu
Copyright (c) 2011 Sam Stephenson
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@@ -1,31 +1,84 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# Summary: Create a Python virtualenv using the pyenv-virtualenv plugin
#
# Usage: pyenv virtualenv [VIRTUALENV_OPTIONS] <version> <virtualenv-name>
# pyenv virtualenv --version
# pyenv virtualenv --help
#
PYENV_VIRTUALENV_VERSION="20130507"
set -e set -e
[ -n "$PYENV_DEBUG" ] && set -x [ -n "$PYENV_DEBUG" ] && set -x
# Provide pyenv completions # Provide pyenv completions
if [ "$1" = "--complete" ]; then if [ "$1" = "--complete" ]; then
exec pyenv versions --bare exec pyenv-versions --bare
fi fi
if [ -z "$PYENV_ROOT" ]; then 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() {
local VIRTUALENV_VERSION="$(pyenv-exec python "${VIRTUALENV}" --version || true)"
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${VIRTUALENV_VERSION:-unknown})"
}
usage() { usage() {
{ echo "usage: pyenv virtualenv [-v|--verbose] [VIRTUALENV_OPTIONS] VERSION VIRTUALENV_NAME" # We can remove the sed fallback once pyenv 0.2.0 is widely available.
echo pyenv-help virtualenv 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0"
echo " -v/--verbose Verbose mode: print compilation status to stdout" pyenv-exec python "${VIRTUALENV}" --help 2>/dev/null || true
echo
} >&2
[ -z "$1" ] || exit "$1" [ -z "$1" ] || exit "$1"
} }
unset VERBOSE PYENV_VIRTUALENV_ROOT="$(abs_dirname "$0")/.."
VIRTUALENV="${PYENV_VIRTUALENV_ROOT}/libexec/pyenv-virtualenv/virtualenv.py"
[ -f "${VIRTUALENV}" ] || VIRTUALENV="${PYENV_VIRTUALENV_ROOT}/libexec/python-virtualenv/virtualenv.py" # backward compatibility before v20130307
[ -f "${VIRTUALENV}" ] || VIRTUALENV="${PYENV_VIRTUALENV_ROOT}/libexec/virtualenv.py"
VIRTUALENV_OPTIONS=() VIRTUALENV_OPTIONS=()
parse_options "$@" parse_options "$@"
@@ -34,11 +87,9 @@ for option in "${OPTIONS[@]}"; do
"h" | "help" ) "h" | "help" )
usage 0 usage 0
;; ;;
"v" | "verbose" )
VERBOSE="-v"
;;
"version" ) "version" )
exec python-virtualenv --version version
exit 0
;; ;;
* ) * )
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--$option" VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--$option"
@@ -79,5 +130,23 @@ 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" # virtualenv may download distribute/setuptools in current directory.
pyenv rehash # change to cache directory to reuse them between invocation.
VIRTUALENV_CACHE_PATH="${PYTHON_BUILD_CACHE_PATH:-${PYENV_ROOT}/cache}"
mkdir -p "${VIRTUALENV_CACHE_PATH}"
{
cd "${VIRTUALENV_CACHE_PATH}"
"${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

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PYTHON_VIRTUALENV_VERSION="20121023" PYTHON_VIRTUALENV_VERSION="20130507"
set -E set -E
exec 3<&2 # preserve original stderr at fd 3 exec 3<&2 # preserve original stderr at fd 3

View File

@@ -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}"

File diff suppressed because it is too large Load Diff