File tree 7 files changed +85
-42
lines changed
7 files changed +85
-42
lines changed Original file line number Diff line number Diff line change 177
177
esac
178
178
179
179
# anaconda/miniconda
180
- if [ -x " ${prefix} /bin/conda" ]; then
180
+ if [ -d " ${prefix} /conda-meta" ] ||
181
+ [ -x " ${prefix} /bin/conda" ]; then
181
182
if [[ " ${prefix} " != " ${prefix%/ envs/* } " ]]; then
182
183
CONDA_DEFAULT_ENV=" ${venv##*/ envs/ } "
183
184
else
233
234
fi
234
235
235
236
# conda package anaconda/miniconda scripts (#173)
236
- if [ -x " ${prefix} /bin/conda" ]; then
237
+ if [ -d " ${prefix} /conda-meta" ] ||
238
+ [ -x " ${prefix} /bin/conda" ]; then
237
239
shopt -s nullglob
238
240
case " ${shell} " in
239
241
fish )
Original file line number Diff line number Diff line change @@ -59,7 +59,8 @@ if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
59
59
fi
60
60
61
61
# conda package anaconda/miniconda scripts (#173)
62
- if [ -x " ${prefix} /bin/conda" ]; then
62
+ if [ -d " ${prefix} /conda-meta" ] ||
63
+ [ -x " ${prefix} /bin/conda" ]; then
63
64
shopt -s nullglob
64
65
case " ${shell} " in
65
66
fish )
Original file line number Diff line number Diff line change @@ -537,10 +537,11 @@ for hook in "${before_hooks[@]}"; do eval "$hook"; done
537
537
538
538
# Plan cleanup on unsuccessful installation.
539
539
cleanup () {
540
+ [[ -L " ${COMPAT_VIRTUALENV_PATH} " ]] && rm " ${COMPAT_VIRTUALENV_PATH} "
540
541
[ -z " ${PREFIX_EXISTS} " ] && rm -rf " $VIRTUALENV_PATH "
541
542
}
542
543
543
- trap cleanup SIGINT
544
+ trap cleanup SIGINT ERR
544
545
545
546
# Invoke virtualenv and record exit status in $STATUS.
546
547
STATUS=0
Original file line number Diff line number Diff line change 6
6
7
7
set -e
8
8
[ -n " $PYENV_DEBUG " ] && set -x
9
+ . " ${BASH_SOURCE%/* } " /../libexec/pyenv-virtualenv-realpath
9
10
10
11
if [ -z " $PYENV_ROOT " ]; then
11
12
PYENV_ROOT=" ${HOME} /.pyenv"
19
20
IFS=: versions=($( pyenv-version-name) )
20
21
fi
21
22
23
+ append_virtualenv_prefix () {
24
+ if [ -d " ${VIRTUALENV_PREFIX_PATH} " ]; then
25
+ VIRTUALENV_PREFIX_PATHS=(" ${VIRTUALENV_PREFIX_PATHS[@]} " " ${VIRTUALENV_PREFIX_PATH:- ${PYENV_PREFIX_PATH} } " )
26
+ else
27
+ echo " pyenv-virtualenv: version \` ${version} ' is not a virtualenv" 1>&2
28
+ exit 1
29
+ fi
30
+ }
31
+
22
32
VIRTUALENV_PREFIX_PATHS=()
23
33
for version in " ${versions[@]} " ; do
24
34
if [ " $version " = " system" ]; then
@@ -55,12 +65,11 @@ for version in "${versions[@]}"; do
55
65
fi
56
66
fi
57
67
fi
58
- if [ -d " ${VIRTUALENV_PREFIX_PATH} " ]; then
59
- VIRTUALENV_PREFIX_PATHS=(" ${VIRTUALENV_PREFIX_PATHS[@]} " " ${VIRTUALENV_PREFIX_PATH:- ${PYENV_PREFIX_PATH} } " )
60
- else
61
- echo " pyenv-virtualenv: version \` ${version} ' is not a virtualenv" 1>&2
62
- exit 1
63
- fi
68
+ append_virtualenv_prefix
69
+ elif [ -d " ${PYENV_PREFIX_PATH} /conda-meta" ]; then
70
+ # conda
71
+ VIRTUALENV_PREFIX_PATH=" $( realpath " ${PYENV_PREFIX_PATH} " /../..) "
72
+ append_virtualenv_prefix
64
73
else
65
74
echo " pyenv-virtualenv: version \` ${version} ' is not a virtualenv" 1>&2
66
75
exit 1
Original file line number Diff line number Diff line change 7
7
8
8
set -e
9
9
[ -n " $PYENV_DEBUG " ] && set -x
10
+ . " ${BASH_SOURCE%/* } " /../libexec/pyenv-virtualenv-realpath
10
11
11
12
if [ -z " $PYENV_ROOT " ]; then
12
13
PYENV_ROOT=" ${HOME} /.pyenv"
32
33
33
34
versions_dir=" ${PYENV_ROOT} /versions"
34
35
35
- if ! enable -f " ${BASH_SOURCE%/* } " /../libexec/pyenv-realpath.dylib realpath 2> /dev/null; then
36
- if [ -n " $PYENV_NATIVE_EXT " ]; then
37
- echo " pyenv: failed to load \` realpath' builtin" >&2
38
- exit 1
39
- fi
40
-
41
- READLINK=$( type -p greadlink readlink | head -1)
42
- if [ -z " $READLINK " ]; then
43
- echo " pyenv: cannot find readlink - are you missing GNU coreutils?" >&2
44
- exit 1
45
- fi
46
-
47
- resolve_link () {
48
- $READLINK " $1 "
49
- }
50
-
51
- realpath () {
52
- local cwd=" $PWD "
53
- local path=" $1 "
54
- local name
55
-
56
- while [ -n " $path " ]; do
57
- name=" ${path##*/ } "
58
- [ " $name " = " $path " ] || cd " ${path%/* } "
59
- path=" $( resolve_link " $name " || true) "
60
- done
61
-
62
- echo " ${PWD} /$name "
63
- cd " $cwd "
64
- }
65
- fi
66
-
67
36
if [ -d " $versions_dir " ]; then
68
37
versions_dir=" $( realpath " $versions_dir " ) "
69
38
fi
Original file line number Diff line number Diff line change
1
+ # newer versions of conda share programs from the real prefix
2
+ # this hook tries to find the executable there
3
+
4
+ if [ ! -x " ${PYENV_COMMAND_PATH} " ] && [[ " ${PYENV_COMMAND_PATH##*/ } " == " conda" ]]; then
5
+ if [ -d " ${PYENV_ROOT} /versions/${version} /conda-meta" ]; then
6
+ conda_command_path=" $( pyenv-virtualenv-prefix " $version " ) " /bin/" ${PYENV_COMMAND_PATH##*/ } "
7
+ if [ -x " ${conda_command_path} " ]; then
8
+ PYENV_COMMAND_PATH=" ${conda_command_path} "
9
+ fi
10
+ fi
11
+ fi
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Summary: Substitute realpath if unavailable as a builtin or file
3
+ # Usage: . pyenv-virtualenv-realpath
4
+
5
+ if ! {
6
+ enable -f " ${BASH_SOURCE%/* } " /../libexec/pyenv-realpath.dylib realpath ||
7
+ type realpath
8
+ } > /dev/null 2>&1 ; then
9
+ if [ -n " $PYENV_NATIVE_EXT " ]; then
10
+ echo " pyenv: failed to load \` realpath' builtin" >&2
11
+ exit 1
12
+ fi
13
+
14
+ READLINK=$( type -p greadlink readlink | head -1)
15
+ if [ -z " $READLINK " ]; then
16
+ echo " pyenv: cannot find readlink - are you missing GNU coreutils?" >&2
17
+ exit 1
18
+ fi
19
+
20
+ resolve_link () {
21
+ $READLINK " $1 "
22
+ }
23
+
24
+ realpath () {
25
+ local f=" $* " \
26
+ name dir
27
+ [[ $f ]] || {
28
+ >&2 echo ${FUNCNAME[0]} : missing operand
29
+ return
30
+ }
31
+ while [[ -L $f ]]; do
32
+ f=" $( resolve_link " $f " ) "
33
+ done
34
+ if [[ ! -d $f ]]; then
35
+ name=" /${f##*/ } "
36
+ # parent?
37
+ dir=" ${f%/* } "
38
+ if [[ $dir == $f ]]; then
39
+ # lacks /: parent is current directory
40
+ f=" $PWD "
41
+ else
42
+ f=" $dir "
43
+ fi
44
+ fi
45
+ # absolute directory
46
+ dir=" $( cd " $f "
47
+ pwd) "
48
+ echo " $dir$name "
49
+ }
50
+ fi
You can’t perform that action at this time.
0 commit comments