From c597947c16cd9fff71402bea51e6e08f13b951ef Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 6 Jun 2024 18:59:06 -0400 Subject: [PATCH] restore exception logging --- pyproject.toml | 2 +- src/fromager/__main__.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a0c6e520..6ca0ebf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ build = [ Repository = "https://github.com/python-wheel-build/fromager" [project.scripts] -fromager = "fromager.__main__:main" +fromager = "fromager.__main__:invoke_main" [project.entry-points."fromager.project_overrides"] # This test plugin should stay in the package. diff --git a/src/fromager/__main__.py b/src/fromager/__main__.py index c9b7a249..824c671b 100644 --- a/src/fromager/__main__.py +++ b/src/fromager/__main__.py @@ -74,5 +74,16 @@ def main(ctx, verbose, log_file, for cmd in commands.commands: main.add_command(cmd) + +def invoke_main(): + # Wrapper for the click main command that ensures any exceptions + # are logged so that build pipeline outputs include the traceback. + try: + main(auto_envvar_prefix='FROMAGER') + except Exception as err: + logger.exception(err) + raise + + if __name__ == '__main__': - main(auto_envvar_prefix='FROMAGER') + invoke_main()