openSUSE / py2pack

Generate distribution packages from PyPI
Apache License 2.0
69 stars 40 forks source link

templates: collect generator output to list before adding to another list #144

Closed bboozzoo closed 3 years ago

bboozzoo commented 3 years ago

When trying to generate a spec for git-machete I get:

$ py2pack generate git-machete -f git-machete.spec
generating spec file for git-machete...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/py2pack/__init__.py", line 365, in main
    args.func(args)
  File "/usr/lib/python3.8/site-packages/py2pack/__init__.py", line 264, in generate
    result = template.render(data).encode('utf-8')                          # render template and encode properly
  File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.8/site-packages/py2pack/templates/opensuse.spec", line 83, in top-level template code
    {%- set scripts_or_console_scripts = (
TypeError: unsupported operand type(s) for +: 'generator' and 'list'

Turns out the, setup.py declares scripts=['git-machete'], which makes jinja2 try running an equivalent of map(os.path.basename, scripts) + [].

mcepl commented 3 years ago

Yes, seems to be obvious.