pyenv-alias
pyenv-alias copied to clipboard
Plugin doesn't work with pyenv >= 2.3.10
When using pyenv 2.3.10 or later, specifying the VERSION_ALIAS seems to have no effect whatsoever.
I suspect that this change (https://github.com/pyenv/pyenv/pull/2568) broke the version aliasing. I also verified that the plugin works correctly with pyenv 2.3.9.
Hi. I’m no longer using pyenv, so it’s unlikely I’ll get to fix this. I’d be happy to accept a pr though …
Thanks, that makes sense. Since my use case for pyenv is quite limited actually, I think I'll just work around it by pinning pyenv to an older version...
I attempted to fix this, but not being much of a bash programmer I was unable to reproduce the previous behaviour. I have created an alternative that allows you to append a suffix to the version name: https://github.com/AdrianDAlessandro/pyenv-suffix
To quickly explain the bug, if it helps fix this plugin...
This plugin sets the VERSION_NAME
variable, but this variable is defined in the code after the entry point for the install hook. There is another entry point that can be accessed by defining the before_install
hook (which is what I've done here, but that is after VERSION_NAME
has already been used to define the PREFIX
(which includes all the path information).
Instead of working out how to pattern-match strings in bash to replace the whole version name at the tail of PREFIX
, I just re-implemented this to add a suffix, which is good enough for my use case.
Another alternative is directly invoking python-build
, which is the default plugin called by pyenv-install
.
For work pyenv-alias on pyenv 2.3.25 patch line 9 etc/pyenv.d/install/alias.bash: old: VERSION_NAME="${VERSION_ALIAS##*/}" new: before_install 'PREFIX="$(dirname ${PREFIX})/${VERSION_ALIAS}"; echo "Installing at ${PREFIX}"'
@igor-buzzoola any chance you can make a PR?
For work pyenv-alias on pyenv 2.3.25 patch line 9 etc/pyenv.d/install/alias.bash: old: VERSION_NAME="${VERSION_ALIAS##*/}" new: before_install 'PREFIX="$(dirname ${PREFIX})/${VERSION_ALIAS}"; echo "Installing at ${PREFIX}"'
It does work but will be the same as the forked one here:
https://github.com/AdrianDAlessandro/pyenv-suffix
I think we may can make it simpler to read and probably easier to add more functions later.
update_prefix_with_version_alias() {
PREFIX="$(dirname ${PREFIX})/${VERSION_ALIAS}"
}
if [ -n "${VERSION_ALIAS}" ]; then
before_install 'update_prefix_with_version_alias'
fi
Providing a suffix instead of a full name has been suggested in https://github.com/pyenv/pyenv/pull/2810 and we're considering adding that into the base product due to apparent considerable demand for the alternate name feature.
Evereyone is welcome to provide feedback on that.
Hi! I'm curious as to the state of this. It looks like a reasonable fix is in @AdrianDAlessandro's fork. Does it simply need to be contributed here @s1341?
Or perhaps the recommendation is to switch to pyenv-suffix
?