mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Download virtualenv.py if specified version has not been installed.
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,6 +1,6 @@
|
||||
/libexec/*.class
|
||||
/libexec/*.pyc
|
||||
/libexec/*.pyo
|
||||
/libexec/__pycache__
|
||||
/libexec/pyenv-virtualenv/*/*.class
|
||||
/libexec/pyenv-virtualenv/*/*.pyc
|
||||
/libexec/pyenv-virtualenv/*/*.pyo
|
||||
/libexec/pyenv-virtualenv/*/__pycache__
|
||||
*.swo
|
||||
*.swp
|
||||
|
||||
@@ -43,7 +43,8 @@ under `~/.pyenv/versions`.
|
||||
#### 2013XXYY
|
||||
|
||||
* Remove `python-virtualenv` which was no longer used.
|
||||
* Change the installation path of the `virtualenv.py` script. (`./libexec` -> `./libexec/pyenv-virtualenv`)
|
||||
* Change the installation path of the `virtualenv.py` script. (`./libexec` -> `./libexec/pyenv-virtualenv/${VIRTUALENV_VERSION}`)
|
||||
* Download `virtualenv.py` if specified version has not been installed.
|
||||
|
||||
#### 20130507
|
||||
|
||||
|
||||
@@ -107,6 +107,15 @@ usage() {
|
||||
[ -z "$1" ] || exit "$1"
|
||||
}
|
||||
|
||||
ensure_virtualenv() {
|
||||
local file="$1"
|
||||
local url="$2"
|
||||
[ -f "${file}" ] || {
|
||||
mkdir -p "$(dirname "${file}")"
|
||||
http get "${url}" "${file}"
|
||||
}
|
||||
}
|
||||
|
||||
PYENV_VIRTUALENV_ROOT="$(abs_dirname "$0")/.."
|
||||
if [ -z "${PYENV_VIRTUALENV_CACHE_PATH}" ]; then
|
||||
PYENV_VIRTUALENV_CACHE_PATH="${PYTHON_BUILD_CACHE_PATH:-${PYENV_ROOT}/cache}"
|
||||
@@ -114,9 +123,14 @@ fi
|
||||
if [ -z "${PYENV_VIRTUALENV_SCRIPT_PATH}" ]; then
|
||||
PYENV_VIRTUALENV_SCRIPT_PATH="${PYENV_VIRTUALENV_ROOT}/libexec/pyenv-virtualenv"
|
||||
fi
|
||||
VIRTUALENV="${PYENV_VIRTUALENV_SCRIPT_PATH}/virtualenv.py"
|
||||
VIRTUALENV="${PYENV_VIRTUALENV_SCRIPT_PATH}/${VIRTUALENV_VERSION}/virtualenv.py"
|
||||
VIRTUALENV_OPTIONS=()
|
||||
|
||||
ensure_virtualenv "${VIRTUALENV}" "https://raw.github.com/pypa/virtualenv/${VIRTUALENV_VERSION}/virtualenv.py" || {
|
||||
echo "pyenv-virtualenv: could not find virtualenv script: ${VIRTUALENV}" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
parse_options "$@"
|
||||
for option in "${OPTIONS[@]}"; do
|
||||
case "$option" in
|
||||
@@ -142,7 +156,7 @@ done
|
||||
|
||||
PYTHON_BIN=$(PYENV_VERSION="${VERSION_NAME}" pyenv-which python)
|
||||
if [ ! -x "${PYTHON_BIN}" ]; then
|
||||
echo "pyenv-virtualenv: could not find python executable: ${PYTHON_BIN}" >&2
|
||||
echo "pyenv-virtualenv: could not find python executable: ${PYTHON_BIN}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ for file in bin/*; do
|
||||
cp "${file}" "${BIN_PATH}"
|
||||
done
|
||||
|
||||
for file in libexec/pyenv-virtualenv/*.py; do
|
||||
cp "${file}" "${LIBEXEC_PATH}"
|
||||
for file in libexec/pyenv-virtualenv/*; do
|
||||
cp -Rp "${file}" "${LIBEXEC_PATH}"
|
||||
done
|
||||
|
||||
echo "Installed pyenv-virtualenv at ${PREFIX}"
|
||||
|
||||
Reference in New Issue
Block a user