asdf-python icon indicating copy to clipboard operation
asdf-python copied to clipboard

Automatically run reshim?

Open fozcodes opened this issue 6 years ago • 11 comments

Hey guys,

I use ASDF for a lot of different langs, but in python anytime I install a new package via pip or pip3 I need to run asdf reshim python to get it to load correctly.

Is this intended behaviour? In other langs, e.g., JS, Elixir, Ruby, you don't need to do this.

Thanks!

fozcodes avatar Jul 21 '18 01:07 fozcodes

Good question. This is clearly and issue for others as well. It could be in the docs at least.

mmartinson avatar Jul 25 '18 16:07 mmartinson

haha, I run into this question every time I get someone new to use asdf.

It's definitely an issue, but because pip isn't a part of asdf I'm not sure that it's within the domain of asdf to modify a workflow. Better documentation is probably the correct solution.

natecox avatar Aug 01 '18 23:08 natecox

🤔 I suppose. But the same argument could be made for bundler in Ruby. Whereas, in Ruby I never have to reshim after installing. Maybe I don't understand the inner workings of pip or pipenv that well. I'm just getting started with Python. It does install the packages as part of the current asdf python and then symlink them, correct?

fozcodes avatar Aug 02 '18 03:08 fozcodes

You’re probably just getting lucky. I’ve had issues with forgetting to reshim for every language I use asdf for; python, ruby, node, elixir, erlang, elm, etc.

It’s inconsistent and I can’t explain what makes it work fine sometimes and poorly others, but certainly not isolated to python.

I imagine virtualenvs switching their own shimming around probably contributes.

natecox avatar Aug 02 '18 05:08 natecox

This is the intended behavior, as I am not a big fan of doing things under the hood. Automatic reshim has caused quite a few issues with npm global installs too. That said, I wouldn't mind accepting a PR to reshim automatically as long as we have a way to disable the behavior (maybe through ~/.asdfrc) Thanks!

danhper avatar Aug 24 '18 11:08 danhper

When would the reshim happen? Is the feature request to wrap pip/pip3 with an asdf-aware script that runs reshim at the end?

tammersaleh avatar Sep 10 '18 20:09 tammersaleh

I know that other tools (e.g. gem for Ruby or npm for Node) offer post-installation hooks, which avoids the need for a wrapper. Do you have any idea if such a hook exists for pip? Otherwise, I think a wrapper could be a decent solution but I wonder if there could be any unwanted side effects?

danhper avatar Sep 20 '18 23:09 danhper

Wouldn't it be possible to just create an aliases that reshims after each install?

e.g. alias gem install="gem install $ && asdf reshim ruby" and then do the same for pip, rust, node etc.

dikaio avatar Nov 30 '18 02:11 dikaio

This is actually quite similar to what pyenv is doing, for example: https://github.com/pyenv/pyenv/blob/d08c9cfb362c5a7e18a92acd2253a16935ad9a99/pyenv.d/exec/pip-rehash/pip I personally do not mind about manually running reshim but is someone wants to send a PR to support this I would not mind merging it either.

danhper avatar Dec 03 '18 07:12 danhper

It looks like in master of asdf right now, there is some new support for auto reshimming.

https://github.com/asdf-vm/asdf/issues/409 https://github.com/asdf-vm/asdf/pull/434

philipbjorge avatar Jan 28 '19 03:01 philipbjorge

thank you @fozcodes for creating this issue, it works well for me for ruby, however, with python, I have to run reshim manually

idoo avatar Mar 27 '20 14:03 idoo