MichaelAquilina / zsh-autoswitch-virtualenv

🐍 ZSH plugin to automatically switch python virtualenvs (including pipenv and poetry) as you move between directories
GNU General Public License v3.0
507 stars 80 forks source link

Drop requirement of pwgen #165

Closed wookayin closed 2 years ago

wookayin commented 2 years ago

I was thinking of submitting a PR directly, but prior to that I wanted to discuss with the owner and make a consensus about the change.

Since v3.3.0 pwgen has became a requirement. However, I don't think it is good idea to require pwgen to make this plugin working.

First, pwgen is only required during mkvenv (with plain virtualenv). Users who are already using pipenv, poetry, conda would never need it. However the startup message saying pwgen is required is annoying for those who actually doesn't need it. Even provided pwgen would be still required, the error could be raised only when it's actually being used.

Second, what pwgen 8 1 does is to simply generate random strings of length 8 (with one numbers). Requiring installing external software for this simple feature would be too much in my opinion. Instead, this could be simply done using python, for example, without any dependencies, as follows:

python3 -c "import string, random; print(''.join(random.choice(string.ascii_letters) for _ in range(8)))"

Although it may look a little verbose and it's not precisely same behavior (e.g., number of digits), but it does the right job of generating a random string.

Third, installing pwgen can be quite confusing in some use cases; it can be installed via apt or brew, but if one installes pwgen via pip (which can happen accidentally), it will not work. Making the plugin fool-proof would be another virtue.

What do you think? Thank you!

MichaelAquilina commented 2 years ago

Hi @wookayin I agree relying on pwgen is not ideal so I'm willing to hear alternatives.

I'm not sure that assuming python is installed is any better though? I'm guessing most installations have it by default, but would it be any higher than pwgen? If the answer is yes, then I would agree that it would be a better alternative but I have not done my research here :)

wookayin commented 2 years ago

This plugin is meant for python, so we can assume that python's availability is very likely. What's the point of using this plugin if they didn't have python3 on PATH? Also, most of the reasonable distribution OS would have python3 available. Windows, might be an exception, though..

MichaelAquilina commented 2 years ago

😂 sorry had some wires crossed when I wrote this message and thought I was posting for another zsh plugin I maintain.

Yes python sounds perfectly reasonable to me. Feel free to open a PR :)

MichaelAquilina commented 2 years ago

This will be solved by #166 once merged