-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[WIP/RFC]: use separate shim paths per version #1185
Conversation
Works quite well for pyenv-shell now already - but no support for fish yet. As for pyenv-local, should we install a chpwd hook ourselves? |
shopt -s extglob | ||
# Remove any shim dir from PATH. | ||
path_without_shims="$(remove_from_path "${PYENV_ROOT}/shims*([^:])")" | ||
PYENV_COMMAND_PATH="$(PATH="$path_without_shims" command -v "$PYENV_COMMAND" || true)" |
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.
This required change breaks github.com/yyuu/pyenv-which-ext, but it is also not necessary with this PR anymore.
(pyenv-which-ext fails to remove the "system" shims dir (which should be empty, but if not (due to a bug) causes an infinite loop)).
2be79c7
to
ddf281d
Compare
Interesting approach! I can definitely see value in fixing |
Hi guys any progress on this one? |
@1oglop1 I am using pyenv myself mainly only for installing different Python versions, and use normal virtualenvs per project (created using |
@blueyed Thanks I will try later, I was happy having it installed via brew, but I will. btw what's But if I understand it correctly it does the same thing as |
You can install it in parallel using |
Not really, sorry. But you can use the method it uses to create the chpwd hook:
|
@blueyed I finally got some time, to play around your branch. I also noticed that number of PRs and Issues is increasing are there enough reviewers @joshfriend because there are opened PRs since 2014 |
54e28cd
to
5cf7b27
Compare
EDIT:
It was because everything executed was first looking for executable in Now I understand jargon word Which means that this branch misses 1 thing.
And EDIT I noticed that I would say that desired behaviour should look as follows:
|
5cf7b27
to
da5ab72
Compare
da5ab72
to
07ebd71
Compare
07ebd71
to
5b6fb13
Compare
…7.3.3 Create pypy3.7-7.3.3-src
…7.3.3-src Create pypy3.7-7.3.3
Use verify_py38 for anaconda3-2020.07
Add PyPy 3.7-7.3.2 (source distribution)
Add PyPy 3.7-7.3.2 (binary distribution)
Add pypy3.7
OS X arm64 will be installed with Python 3.9 only. Other versions bundled with python 3.8. Miniforge does not have as wide a choice of python versions as miniconda. The Python version is specific only to the base environment.
Added Miniforge 3
corrected fish shell command
more general installation readme instructions
Ref: pyenv#1112 Add PYENV_SHIM, and use it with remove_from_path This is required to avoid infinite recursion with "system" version. Could also use PYENV_SHIM_PATH, but having PYENV_SHIM is more flexible/useful. Uses the following in ~/.autoenv.zsh: ```zsh # Experimental: maintain separate shims dir for pyenv. local version if [[ -z "$PYENV_VERSION" ]]; then version=$(pyenv version-name) elif [[ -n "$_CUSTOM_PYENV_VERSION" ]]; then if [[ "$_CUSTOM_PYENV_VERSION" == "$PYENV_VERSION" ]]; then version=$(pyenv version-name) echo "Updating custom pyenv version ($_CUSTOM_PYENV_VERSION => $version)" else echo "PYENV_VERSION was changed manually, unsetting _CUSTOM_PYENV_VERSION" unset _CUSTOM_PYENV_VERSION fi fi # echo version=$version PYENV_VERSION=$PYENV_VERSION if [[ -n "$version" ]] && [[ "$version" != "$PYENV_VERSION" ]]; then echo "pyenv version changed ($PYENV_VERSION => $version)" shims_dir=$PYENV_ROOT/shims # Create shims for this version, once. if ! [[ -d $shims_dir/$version ]]; then echo "pyenv-rehash via $0 for $version" PYENV_SHIM_PATH=$shims_dir/$version pyenv rehash fi if [[ -z "$_CUSTOM_PYENV_SHIMDIR" ]]; then _CUSTOM_PYENV_SHIMDIR=$(mktemp -d --tmpdir pyenv_shims.XXX) PATH=${PATH//$shims_dir/$_CUSTOM_PYENV_SHIMDIR} rmdir $_CUSTOM_PYENV_SHIMDIR ln -s $shims_dir/$version $_CUSTOM_PYENV_SHIMDIR fi PYENV_VERSION=$version _CUSTOM_PYENV_VERSION=$version # mv ~/.pyenv/shims ~/.pyenv/shims.out # ln -s $_CUSTOM_PYENV_SHIMDIR ~/.pyenv/shims \ # && pyenv rehash \ # && rm ~/.pyenv/shims \ # && mv ~/.pyenv/shims.out ~/.pyenv/shims fi ```
Only removing the current one could result in the system version not being found, e.g. when using the following: out=$(PATH=$PYENV_ROOT/libexec:$PATH pyenv-sh-shell $version | grep '^PATH')
…ely be just silent
":" could work on Unix, but likely not on Windows? Would need to be handled/escaped in updated_path_for_shims then - currently it would loop endlessly.
…him dirs automatically
It gets not done during init now anymore. Initially I was about to only remove the "2>/dev/null" redirection, to see the intermediate message 'pyenv-rehash: should not be used with "system" version', but it should not be necessary at all anymore.
This PR is now so polluted with unrelated commits that I cannot see what it actually does. In particular, I don't see the coveted "chdir hook" that must be the key to its usability. |
@native-api
There's an example for one in Zsh in the description itself. |
Main motivation:
which foo
should not return a pyenv shim in casefoo
is installed in some environment, but not the current.This is a main issue with pyenv, and this fixes it.
Ref: #1112
Add PYENV_SHIM, and use it with remove_from_path
This is required to avoid infinite recursion with "system" version.
Could also use PYENV_SHIM_PATH, but having PYENV_SHIM is more
flexible/useful.
TODO:
Uses the following chpwd handler (Zsh), e.g. via
zsh-autoenv:
Drawbacks:
calls
pyenv version-name
every time you change a directory (ifpyenv-shell
was not used). This could be optimized e.g. by looking for the.python-version
file only./cc @yyuu @mislav