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
{{ message }}
Repository navigation
Documented direct wheel execution fails before the __main__ bootstrap runs #530
What OS are you using? (Add more in the Environment section)
Linux
Situation
semver/__main__.py documents that a wheel can be run directly like this:
$ python3 semver-3*-py3-none-any.whl/semver -h
That invocation currently fails before the compatibility bootstrap in main() can run. The module imports from semver import cli at top level, but the wheel path is inserted into sys.path only later inside main().
Traceback (most recent call last):
...
File ".../semver-3.2.0-py3-none-any.whl/semver/__main__.py", line 17, in <module>
from semver import cli
ModuleNotFoundError: No module named 'semver'
For comparison, using the wheel as a normal sys.path entry works:
The documented direct-wheel invocation should display the CLI help instead of raising ModuleNotFoundError.
A possible resolution would be to perform the __package__ == "" path adjustment before importing semver.cli, or to move the cli import inside main() after that adjustment. I would be happy to implement either approach with a regression test if you think this documented execution mode should continue to be supported.
Environment
Reproduced with the semver 3.2.0 wheel from PyPI on CPython 3.10/Linux. The same import order is present on current master.
Activity