mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-13 05:53:52 -05:00
*EXPERIMENTAL* a support for _envs_ created by anaconda/miniconda
This commit is contained in:
@@ -31,7 +31,8 @@ base_prefix() { # pyvenv
|
||||
}
|
||||
|
||||
VIRTUALENV_PREFIX_PATHS=()
|
||||
for version in "${versions[@]}"; do
|
||||
for version_string in "${versions[@]}"; do
|
||||
version="${version_string%%/*}"
|
||||
if [ "$version" = "system" ]; then
|
||||
echo "pyenv-virtualenv: version \`${version}' is not a virtualenv" 1>&2
|
||||
exit 1
|
||||
@@ -40,8 +41,18 @@ for version in "${versions[@]}"; do
|
||||
if [ -f "${PREFIX}/bin/activate" ]; then
|
||||
# Anaconda has `activate` script nevertheless it is not a virtual environment (#65)
|
||||
if [ -f "${PREFIX}/bin/conda" ]; then
|
||||
echo "pyenv-virtualenv: version \`${version}' is an anaconda/miniconda" 1>&2
|
||||
exit 1
|
||||
if [[ "${version_string}" != "${version_string%/envs/*}" ]]; then
|
||||
conda_env="${version_string##*/envs/}"
|
||||
if [ -f "${PREFIX}/envs/${conda_env}/bin/conda" ]; then
|
||||
VIRTUALENV_PREFIX_PATHS=("${VIRTUALENV_PREFIX_PATHS[@]}" "${PREFIX}/envs/${conda_env}")
|
||||
else
|
||||
echo "pyenv-virtualenv: version \`${version_string}' is not an environment of anaconda/miniconda" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "pyenv-virtualenv: version \`${version_string}' is not a virtualenv" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
VIRTUALENV_PREFIX_PATH="$(real_prefix "${version}" || base_prefix "${version}" || true)"
|
||||
VIRTUALENV_PREFIX_PATHS=("${VIRTUALENV_PREFIX_PATHS[@]}" "$VIRTUALENV_PREFIX_PATH")
|
||||
|
||||
@@ -51,6 +51,16 @@ for version in $(pyenv-versions --bare); do
|
||||
virtualenv_prefix="$(pyenv-virtualenv-prefix "${version}" 2>/dev/null || true)"
|
||||
if [ -d "${virtualenv_prefix}" ]; then
|
||||
print_version "${version}" " (created from ${virtualenv_prefix})"
|
||||
else
|
||||
# envs of anaconda/miniconda
|
||||
prefix="$(pyenv-prefix "${version}")"
|
||||
if [ -f "${prefix}/bin/activate" ] && [ -f "${prefix}/bin/conda" ]; then
|
||||
shopt -s nullglob
|
||||
for conda_env in "${prefix}/envs/"*; do
|
||||
print_version "${version##*/}${conda_env#${prefix}}" " (created from ${prefix})"
|
||||
done
|
||||
shopt -u nullglob
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user