Skip to content

Commit 14b27b5

Browse files
authored
editable: exit script with callable return
This change ensures that generated scripts for editable package installs exit using return value from callable used.
1 parent 0d7b16f commit 14b27b5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

poetry/masonry/builders/editable.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727

2828
SCRIPT_TEMPLATE = """\
2929
#!{python}
30+
import sys
3031
from {module} import {callable_holder}
3132
3233
if __name__ == '__main__':
33-
{callable_}()
34+
sys.exit({callable_}())
3435
"""
3536

3637
WINDOWS_CMD_TEMPLATE = """\

tests/masonry/builders/test_editable_builder.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_
148148

149149
baz_script = """\
150150
#!{python}
151+
import sys
151152
from bar import baz
152153
153154
if __name__ == '__main__':
154-
baz.boom.bim()
155+
sys.exit(baz.boom.bim())
155156
""".format(
156157
python=tmp_venv.python
157158
)
@@ -160,10 +161,11 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_
160161

161162
foo_script = """\
162163
#!{python}
164+
import sys
163165
from foo import bar
164166
165167
if __name__ == '__main__':
166-
bar()
168+
sys.exit(bar())
167169
""".format(
168170
python=tmp_venv.python
169171
)
@@ -172,10 +174,11 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_
172174

173175
fox_script = """\
174176
#!{python}
177+
import sys
175178
from fuz.foo import bar
176179
177180
if __name__ == '__main__':
178-
bar.baz()
181+
sys.exit(bar.baz())
179182
""".format(
180183
python=tmp_venv.python
181184
)

0 commit comments

Comments
 (0)