Commit b751603d authored by Jérome Perrin's avatar Jérome Perrin Committed by Kirill Smelkov

pyprog: Wrap entry-point call with sys.exit()

Reading this spec, we probably want to change
```
  entry_run = 'from %s import %s; %s()' % (mod, func, func)
```
to
```
  entry_run = 'import sys; from %s import %s; sys.exit(%s())' % (mod, func, func)
```
to follow
https://packaging.python.org/en/latest/specifications/entry-points/#use-for-scripts
, this is also what `zc.recipe.egg` does.

/reviewed-by @kirr
/reviewed-on nexedi/slapos!1108
parent 0ee52376
......@@ -77,9 +77,9 @@ init =
options['depends'] += '$${.%s.pyprog:recipe}' % name
# mod:func -> 'from mod import func; func()'
# mod:func -> 'from mod import func; sys.exit(func())'
mod, func = entry.split(':')
entry_run = 'from %s import %s; %s()' % (mod, func, func)
entry_run = 'from %s import %s; sys.exit(%s())' % (mod, func, func)
# indent pyinit with ' '
__pyinit = '\n'.join([' '+_ for _ in pyinit.splitlines()])
......@@ -95,6 +95,7 @@ init =
template=
inline:
#!$${.%(name)s.pyexe:exe}
import sys
%(__pyinit)s
%(entry_run)s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment