-
-
Notifications
You must be signed in to change notification settings - Fork 421
Fix: support newer conda #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# newer versions of conda share programs from the real prefix | ||
# this hook tries to find the executable there | ||
|
||
if [ ! -x "${PYENV_COMMAND_PATH}" ] && [[ "${PYENV_COMMAND_PATH##*/}" == "conda" ]]; then | ||
if [ -d "${PYENV_ROOT}/versions/${version}/conda-meta" ]; then | ||
conda_command_path="$(pyenv-virtualenv-prefix "$version")"/bin/"${PYENV_COMMAND_PATH##*/}" | ||
if [ -x "${conda_command_path}" ]; then | ||
PYENV_COMMAND_PATH="${conda_command_path}" | ||
fi | ||
fi | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
# Summary: Substitute realpath if unavailable as a builtin or file | ||
# Usage: . pyenv-virtualenv-realpath | ||
|
||
if ! { | ||
enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath || | ||
type realpath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to have this condition? At least this is something new and I'd like to know your intention of this new condition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose is to skip defining unneeded substitutes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine to use GNU coreutils feature as long as we have fallback code for where the platform without it. My point was that there was no such condition before you split the code into library condition and would like to know your intention for the change. |
||
} >/dev/null 2>&1; then | ||
if [ -n "$PYENV_NATIVE_EXT" ]; then | ||
echo "pyenv: failed to load \`realpath' builtin" >&2 | ||
exit 1 | ||
fi | ||
|
||
READLINK=$(type -p greadlink readlink | head -1) | ||
if [ -z "$READLINK" ]; then | ||
echo "pyenv: cannot find readlink - are you missing GNU coreutils?" >&2 | ||
exit 1 | ||
fi | ||
|
||
resolve_link() { | ||
$READLINK "$1" | ||
} | ||
|
||
realpath() { | ||
local f="$*" \ | ||
name dir | ||
[[ $f ]] || { | ||
>&2 echo ${FUNCNAME[0]}: missing operand | ||
return | ||
} | ||
while [[ -L $f ]]; do | ||
f="$(resolve_link "$f")" | ||
done | ||
if [[ ! -d $f ]]; then | ||
name="/${f##*/}" | ||
# parent? | ||
dir="${f%/*}" | ||
if [[ $dir == $f ]]; then | ||
#lacks /: parent is current directory | ||
f="$PWD" | ||
else | ||
f="$dir" | ||
fi | ||
fi | ||
#absolute directory | ||
dir="$(cd "$f" | ||
pwd)" | ||
echo "$dir$name" | ||
} | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have "set -e" in all scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that.
However, are you aware this is an inline shell file and not a proper script?
It's never run on it's own.
It's always run inline/
source
d inside another script already doingset -e
.It's really like a reusable, incomplete section of larger script, like the files under
pyenv.d
.Should I rename it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I was overlooking that this script was placed umder libexec dir. It's fine without -e.