You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Click is used inside zipapps produced by Shiv or PEX, it displays an invalid "Usage" string. Instead of "Usage: program" it says "Usage: python -m program".
I did some digging and found that this is due to info_name being guessed incorrectly in the code introduced by #1609. There is a test for __package__ being set to None; however, in the case when the script is run inside Shiv or PEX, __package__ is instead set to the empty string (""). This is allowed by PEP 366:
Note that setting package to the empty string explicitly is permitted, and has the effect of disabling all relative imports from that module (since the import machinery will consider it to be a top level module in that case).
Hey, thanks! I didn't realize that parameter existed. That's good to know. 😊
However, this used to work out of the box until #1609, so I would prefer if we could restore it. This bug has prevented me from upgrading from Click 7 for the longest time, which is why I finally found the energy to fix the problem and create a PR. 😉
Summary
When Click is used inside zipapps produced by Shiv or PEX, it displays an invalid "Usage" string. Instead of "Usage: program" it says "Usage: python -m program".
I did some digging and found that this is due to info_name being guessed incorrectly in the code introduced by #1609. There is a test for
__package__
being set toNone
; however, in the case when the script is run inside Shiv or PEX,__package__
is instead set to the empty string (""). This is allowed by PEP 366:Reproducing
Follow the basic Shiv hello world example, but add Click:
hello.py:
setup.py:
Build the executable zipapps and run them:
Expected behavior
Click should not print the Usage string as "python -m hello"; it should just be "hello".
Environment:
The text was updated successfully, but these errors were encountered: