From 1d9268c5e96610fb9d11a8a7450a362612fec9c3 Mon Sep 17 00:00:00 2001 From: Cyril Jouve Date: Mon, 30 Aug 2021 22:51:44 +0200 Subject: [PATCH] exit with callable exit code in generated script the behaviour is consistent with pip --- poetry/masonry/builders/editable.py | 3 ++- tests/masonry/builders/test_editable_builder.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/poetry/masonry/builders/editable.py b/poetry/masonry/builders/editable.py index 2483a5ec704..52d42b8dab5 100644 --- a/poetry/masonry/builders/editable.py +++ b/poetry/masonry/builders/editable.py @@ -27,10 +27,11 @@ SCRIPT_TEMPLATE = """\ #!{python} +import sys from {module} import {callable_holder} if __name__ == '__main__': - {callable_}() + sys.exit({callable_}()) """ WINDOWS_CMD_TEMPLATE = """\ diff --git a/tests/masonry/builders/test_editable_builder.py b/tests/masonry/builders/test_editable_builder.py index 6fb0a07a445..270b1d80c75 100644 --- a/tests/masonry/builders/test_editable_builder.py +++ b/tests/masonry/builders/test_editable_builder.py @@ -148,10 +148,11 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_ baz_script = """\ #!{python} +import sys from bar import baz if __name__ == '__main__': - baz.boom.bim() + sys.exit(baz.boom.bim()) """.format( python=tmp_venv.python ) @@ -160,10 +161,11 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_ foo_script = """\ #!{python} +import sys from foo import bar if __name__ == '__main__': - bar() + sys.exit(bar()) """.format( python=tmp_venv.python ) @@ -172,10 +174,11 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_ fox_script = """\ #!{python} +import sys from fuz.foo import bar if __name__ == '__main__': - bar.baz() + sys.exit(bar.baz()) """.format( python=tmp_venv.python )