pyenv-alias icon indicating copy to clipboard operation
pyenv-alias copied to clipboard

Plugin doesn't work with pyenv >= 2.3.10

Open AndreyBozhko opened this issue 2 years ago • 11 comments

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.

AndreyBozhko avatar Jan 24 '23 17:01 AndreyBozhko

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 …

s1341 avatar Jan 24 '23 17:01 s1341

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...

AndreyBozhko avatar Jan 30 '23 00:01 AndreyBozhko

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.

AdrianDAlessandro avatar Feb 07 '23 23:02 AdrianDAlessandro

Another alternative is directly invoking python-build, which is the default plugin called by pyenv-install.

IvanaGyro avatar Jul 31 '23 09:07 IvanaGyro

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 avatar Aug 29 '23 11:08 igor-buzzoola

@igor-buzzoola any chance you can make a PR?

s1341 avatar Aug 30 '23 06:08 s1341

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

tchayintr avatar Sep 07 '23 02:09 tchayintr

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

tchayintr avatar Sep 08 '23 04:09 tchayintr

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.

native-api avatar Oct 06 '23 20:10 native-api

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?

pshriwise avatar Oct 26 '23 15:10 pshriwise

Or perhaps the recommendation is to switch to pyenv-suffix?

pshriwise avatar Oct 26 '23 15:10 pshriwise