Don't ignore exit codes when using setuptools entry points#280
Conversation
Setuptools does not require `console_scripts` entry points to call
`sys.exit()` (or similar) to exit non-zero:
The functions you specify are called with no arguments, and their
return value is passed to `sys.exit()`, so you can return an
errorlevel or message to print to stderr
This patch updates pex to follow the same behavior.
Fixes pex-tool#137.
| # setuptools < 11.3 | ||
| runner = entry.load(require=False) | ||
| runner() | ||
| sys.exit(runner()) |
There was a problem hiding this comment.
this seems like an awkward place to sys.exit - esp as potentially called by a library consumer. is there no better path to plumbing the return value/execution context and sys.exit'ing at the end of PEX.execute()?
at a minimum, moving this to either PEX.execute_script() or its calling branch in PEX._execute() would make slightly more sense to me given the context.
There was a problem hiding this comment.
I thought about that, but most packages will already have done a sys.exit() or raise SystemExit here anyways, including pex. I can still move it if you'd like
There was a problem hiding this comment.
I pushed a commit moving it so this should be ready to merge either way
There was a problem hiding this comment.
there is the generic case of non-console script entry point execution to consider, esp as used as a library - moving it to execute_script() works for me tho.
There was a problem hiding this comment.
Oh, definitely did not consider that
|
thanks for the PR @rouge8 ! |
Setuptools does not require
console_scriptsentry points to callsys.exit()(or similar) to exit non-zero:This patch updates pex to follow the same behavior.
Fixes #137.