asdf-python
asdf-python copied to clipboard
Automatically run reshim?
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!
Good question. This is clearly and issue for others as well. It could be in the docs at least.
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.
🤔 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?
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.
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!
When would the reshim happen? Is the feature request to wrap pip
/pip3
with an asdf-aware script that runs reshim
at the end?
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?
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.
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.
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
thank you @fozcodes for creating this issue, it works well for me for ruby, however, with python, I have to run reshim manually