Only use premitives in which hooks to avoid infinite loop (#104)

This commit is contained in:
Yamashita, Yuu
2015-11-26 12:39:15 +00:00
parent bdda7214a8
commit c3d044d70a
2 changed files with 34 additions and 11 deletions

View File

@@ -4,11 +4,28 @@
# https://github.com/yyuu/pyenv/issues/397
if [ ! -x "${PYENV_COMMAND_PATH}" ] && [[ "${PYENV_COMMAND_PATH##*/}" == "python"*"-config" ]]; then
virtualenv_prefix="$(pyenv-virtualenv-prefix 2>/dev/null || true)"
if [ -d "${virtualenv_prefix}" ]; then
virtualenv_command_path="${virtualenv_prefix}/bin/${PYENV_COMMAND_PATH##*/}"
if [ -x "${virtualenv_command_path}" ]; then
PYENV_COMMAND_PATH="${virtualenv_command_path}"
OLDIFS="${IFS}"
IFS=:
version="$(pyenv-version-name)"
IFS="${OLDIFS}"
if [ -f "${PYENV_ROOT}/versions/${version}/bin/activate" ]; then
if [ -f "${PYENV_ROOT}/versions/${version}/bin/conda" ]; then
: # do nothing for conda's environments
else
if [ -f "${PYENV_ROOT}/versions/${version}/bin/pyvenv.cfg" ]; then
# pyvenv
virtualenv_binpath="$(cut -b 1-1024 "${PYENV_ROOT}/versions/${version}/pyvenv.cfg" | sed -n '/^ *home *= */s///p' || true)"
virtualenv_prefix="${virtualenv_binpath%/bin}"
else
# virtualenv
shopt -s nullglob
virtualenv_prefix="$(cat "${PYENV_ROOT}/versions/${version}/lib/"*"/orig-prefix.txt" </dev/null 2>&1 || true)"
shopt -u nullglob
fi
virtualenv_command_path="${virtualenv_prefix}/bin/${PYENV_COMMAND_PATH##*/}"
if [ -x "${virtualenv_command_path}" ]; then
PYENV_COMMAND_PATH="${virtualenv_command_path}"
fi
fi
fi
fi

View File

@@ -4,21 +4,27 @@
# https://github.com/yyuu/pyenv-virtualenv/issues/62
if [ ! -x "${PYENV_COMMAND_PATH}" ]; then
virtualenv_prefix="$(pyenv-virtualenv-prefix 2>/dev/null || true)"
if [ -d "$(pyenv-prefix)" ] && [ -d "${virtualenv_prefix}" ]; then
OLDIFS="${IFS}"
IFS=:
version="$(pyenv-version-name)"
IFS="${OLDIFS}"
if [ -f "${PYENV_ROOT}/versions/${version}/bin/activate" ]; then
unset include_system_site_packages
if [ -f "$(pyenv-prefix)/bin/conda" ]; then
if [ -f "${PYENV_ROOT}/versions/${version}/bin/conda" ]; then
: # do nothing for conda's environments
else
if [ -f "$(pyenv-prefix)/pyvenv.cfg" ]; then
if [ -f "${PYENV_ROOT}/versions/${version}/pyvenv.cfg" ]; then
# pyvenv
if grep -q -i "include-system-site-packages *= *true" "$(pyenv-prefix)/pyvenv.cfg" 1>/dev/null 2>&1; then
virtualenv_binpath="$(cut -b 1-1024 "${PYENV_ROOT}/versions/${version}/pyvenv.cfg" | sed -n '/^ *home *= */s///p' || true)"
virtualenv_prefix="${virtualenv_binpath%/bin}"
if grep -q -i "include-system-site-packages *= *true" "${PYENV_ROOT}/versions/${version}/pyvenv.cfg" 1>/dev/null 2>&1; then
include_system_site_packages=1
fi
else
# virtualenv
shopt -s nullglob
no_global_site_packages="$(echo "$(pyenv-prefix)/lib/"*"/no-global-site-packages.txt")"
virtualenv_prefix="$(cat "${PYENV_ROOT}/versions/${version}/lib/"*"/orig-prefix.txt" </dev/null 2>&1 || true)"
no_global_site_packages="$(echo "${PYENV_ROOT}/versions/${version}/lib/"*"/no-global-site-packages.txt")"
shopt -u nullglob
if [ ! -f "${no_global_site_packages}" ]; then
include_system_site_packages=1