Skip to content

Commit

Permalink
Download virtualenv.py if specified version has not been installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashita Yuu committed May 7, 2013
1 parent a9903fa commit db37bb9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .gitignore
@@ -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
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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

Expand Down
18 changes: 16 additions & 2 deletions bin/pyenv-virtualenv
Expand Up @@ -107,16 +107,30 @@ 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}"
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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions install.sh
Expand Up @@ -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}"
File renamed without changes.

0 comments on commit db37bb9

Please sign in to comment.