mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-09 20:13:54 -05:00
create project
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.swo
|
||||||
|
*.swp
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Copyright (c) 2012 Yamashita, Yuu
|
||||||
|
Copyright (c) 2011 Sam Stephenson
|
||||||
|
|
||||||
|
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.
|
||||||
69
README.md
Normal file
69
README.md
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# python-virtualenv
|
||||||
|
|
||||||
|
python-virtualenv is an [pyenv](https://github.com/yyuu/pyenv) plugin
|
||||||
|
that provides an `pyenv virtualenv` command to create virtualenv for Python
|
||||||
|
on UNIX-like systems.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Installing as an pyenv plugin (recommended)
|
||||||
|
|
||||||
|
Installing python-virtualenv as an pyenv plugin will give you access to the
|
||||||
|
`pyenv virtualenv` command.
|
||||||
|
|
||||||
|
$ mkdir -p ~/.pyenv/plugins
|
||||||
|
$ cd ~/.pyenv/plugins
|
||||||
|
$ git clone git://github.com/yyuu/python-virtualenv.git
|
||||||
|
|
||||||
|
This will install the latest development version of python-virtualenv into
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### 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 2.7.3 venv27
|
||||||
|
|
||||||
|
virtualenvs will be created into a directory of the same name
|
||||||
|
under `~/.pyenv/versions`.
|
||||||
|
|
||||||
|
|
||||||
|
## Version History
|
||||||
|
|
||||||
|
#### 20120927
|
||||||
|
|
||||||
|
* Initial public release.
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Yamashita, Yuu
|
||||||
|
Copyright (c) 2011 Sam Stephenson
|
||||||
|
|
||||||
|
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.
|
||||||
61
bin/pyenv-virtualenv
Executable file
61
bin/pyenv-virtualenv
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
# Provide pyenv completions
|
||||||
|
if [ "$1" = "--complete" ]; then
|
||||||
|
exec pyenv versions --bare
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PYENV_ROOT" ]; then
|
||||||
|
PYENV_ROOT="${HOME}/.pyenv"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load shared library functions
|
||||||
|
eval "$(python-virtualenv --lib)"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
{ echo "usage: pyenv virtualenv [-v|--verbose] [VIRTUALENV_OPTIONS] PYTHON_VERSION NAME"
|
||||||
|
echo
|
||||||
|
echo " -v/--verbose Verbose mode: print compilation status to stdout"
|
||||||
|
echo
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
[ -z "$1" ] || exit "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
unset VERBOSE
|
||||||
|
|
||||||
|
VIRTUALENV_OPTIONS=()
|
||||||
|
|
||||||
|
parse_options "$@"
|
||||||
|
for option in "${OPTIONS[@]}"; do
|
||||||
|
case "$option" in
|
||||||
|
"h" | "help" )
|
||||||
|
usage 0
|
||||||
|
;;
|
||||||
|
"v" | "verbose" )
|
||||||
|
VERBOSE="-v"
|
||||||
|
;;
|
||||||
|
"version" )
|
||||||
|
exec python-virtualenv --version
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--$option"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
VERSION_NAME="${ARGUMENTS[0]}"
|
||||||
|
[ -n "$VERSION_NAME" ] || usage 1
|
||||||
|
|
||||||
|
for script in $(pyenv-hooks virtualenv); do
|
||||||
|
source "$script"
|
||||||
|
done
|
||||||
|
|
||||||
|
PYTHON_PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
|
||||||
|
VIRTUALENV_NAME="${ARGUMENTS[1]##*/}"
|
||||||
|
VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
|
||||||
|
|
||||||
|
python-virtualenv $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "$PYTHON_PREFIX" "$VIRTUALENV_PATH"
|
||||||
|
pyenv rehash
|
||||||
118
bin/python-virtualenv
Executable file
118
bin/python-virtualenv
Executable file
@@ -0,0 +1,118 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
PYTHON_VIRTUALENV_VERSION="20120927"
|
||||||
|
|
||||||
|
set -E
|
||||||
|
exec 3<&2 # preserve original stderr at fd 3
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" == "--$FUNCNAME" ]; then
|
||||||
|
declare -f "$FUNCNAME"
|
||||||
|
echo "$FUNCNAME \"\$1\";"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
lib "$1"
|
||||||
|
|
||||||
|
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 "python-virtualenv ${PYTHON_VIRTUALENV_VERSION}"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
{ version
|
||||||
|
echo "usage: python-virtualenv [-v|--verbose] [VIRTUALENV_OPTIONS] python_prefix virtualenv_path"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
unset VERBOSE
|
||||||
|
PYTHON_VIRTUALENV_ROOT="$(abs_dirname "$0")/.."
|
||||||
|
VIRTUALENV_OPTIONS=()
|
||||||
|
|
||||||
|
parse_options "$@"
|
||||||
|
|
||||||
|
for option in "${OPTIONS[@]}"; do
|
||||||
|
case "$option" in
|
||||||
|
"h" | "help" )
|
||||||
|
usage without_exiting
|
||||||
|
{ echo
|
||||||
|
echo " -v/--verbose Verbose mode: print compilation status to stdout"
|
||||||
|
echo
|
||||||
|
} >&2
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"v" | "verbose" )
|
||||||
|
VERBOSE=true
|
||||||
|
;;
|
||||||
|
"version" )
|
||||||
|
version
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--$option"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
PYTHON_PREFIX="${ARGUMENTS[0]}"
|
||||||
|
if [ -z "$PYTHON_PREFIX" ]; then
|
||||||
|
usage
|
||||||
|
elif [ ! -x "${PYTHON_PREFIX}/bin/python" ]; then
|
||||||
|
echo "python-virtualenv: python not found: ${PYTHON_PREFIX}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VIRTUALENV_PATH="${ARGUMENTS[1]}"
|
||||||
|
if [ -z "$VIRTUALENV_PATH" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
PYTHON_BIN="${PYTHON_PREFIX}/bin/python"
|
||||||
|
CWD="$(pwd)"
|
||||||
|
|
||||||
|
"${PYTHON_BIN}" "${PYTHON_VIRTUALENV_ROOT}/libexec/virtualenv.py" --python="${PYTHON_BIN}" "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}"
|
||||||
2475
libexec/virtualenv.py
Normal file
2475
libexec/virtualenv.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user