I am maintaining an internal python package with a number of utility functions. As part of this package, I included a project generator console_script
which calls cookiecutter using a custom template that is shipped with the package. This works fine when installing the package using pip
(basically, as an sdist).
I am trying to get people to use conda
as much as possible, so this is inconvenient as dependencies get resolved/installed using pip
, not conda
. Therefore, I am creating a conda package using the python setup.py bdist_conda
way that is included by the Anaconda install. This works well, afaict, for another internal package.
However, when I try to create the present package, the bdist_conda
creation byte-compiles all the python files in the package, so of course (but unintended) also the template files. This leads to a syntax error, because of the jinja strings, when running python setup.py bdist_conda
:
byte-compiling build/bdist.linux-x86_64/dumb/home/bilderbuchi/anaconda3/lib/python3.5/site-packages/mypkg/project_template/{{cookiecutter.project_name_simplified}}/{{cookiecutter.project_name_simplified}}.py to {{cookiecutter.project_name_simplified}}.cpython-35.pyc
File "/path/to/mypkg/project_template/{{cookiecutter.project_name_simplified}}/{{cookiecutter.project_name_simplified}}.py", line 4
{%- if cookiecutter.command_line_interface == 'argparse' %}
^
SyntaxError: invalid syntax
I also can reproduce with a plain python setup.py bdist
, so I can exclude conda from being the culprit here.
I add the template files with a MANIFEST.in
containing recursive-include mypkg/project_template *
, and include_package_data = True
in the setuptools-based setup.py
.
Is there a (better) way to ship a cookiecutter template with some package? As I said, this works nicely when used withpip
/sdist, but fails with bdist
.
Alternatively, is there a way to suppress bdist byte-compiling a given set of files?
The template cannot be placed online, which is why I want to include it in the package. I also considered placing the template, separately, elsewhere, but then users depend on that location (e.g. network drive) being available when they use the project generator. I looked at adding it as a zip file, but apart from this being super unconvenient from a version control point of view, apparently, users will be prompted to delete the existing (I guess unpacked to some user location) template on the next run, so I'd rather avoid that.
- Cookiecutter version: 1.6.0
- Python version: 3.5
- setuptools 38.5.1
- Operating System: Linux
Edit: I also posted this in the cookiecutter issue tracker, but didn't get any feedback so far.