Skip to content

Commit b024f63

Browse files
committed
A bit of template cleanup (a bunch of duplication removed) and fixes for the pypy envs. Coveralls can now be enabled for appveyor, coverage submissions will work on pypy3, codacy has a cookiecutter input for the token.
1 parent 33737e2 commit b024f63

File tree

9 files changed

+76
-246
lines changed

9 files changed

+76
-246
lines changed

cookiecutter.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
"command_line_interface": ["plain", "argparse", "click", "no"],
4141
"command_line_interface_bin_name": "{{ cookiecutter.distribution_name }}",
4242
"coveralls": ["no", "yes"],
43+
"coveralls_token": "Required for Appveyor, take it from https://coveralls.io/github/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}",
4344
"codecov": ["yes", "no"],
4445
"landscape": ["no", "yes"],
4546
"scrutinizer": ["no", "yes"],
4647
"codacy" : ["no", "yes"],
48+
"codacy_projectid" : "Get ID from https://app.codacy.com/app/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/settings",
4749
"codeclimate" : ["no", "yes"],
4850
"sphinx_docs": ["yes", "no"],
4951
"sphinx_theme": ["sphinx-rtd-theme", "sphinx-py3doc-enhanced-theme"],

hooks/post_gen_project.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,6 @@ def replace_contents(filename, what, replacement):
3333
shutil.rmtree('docs')
3434
{% endif %}
3535

36-
{% if cookiecutter.test_matrix_configurator == "yes" %}
37-
print("""
38-
################################################################################
39-
40-
For your convenience, the test environments are getting configured for the
41-
first time, as you have selected "yes" for `test_matrix_configurator` ...
42-
""")
43-
try:
44-
subprocess.check_call(['tox'])
45-
except Exception:
46-
try:
47-
subprocess.check_call([sys.executable, '-mtox'])
48-
except Exception:
49-
subprocess.check_call([sys.executable, join('ci', 'bootstrap.py')])
50-
{% endif %}
51-
5236
{%- if cookiecutter.command_line_interface == 'no' %}
5337
os.unlink(join('src', '{{ cookiecutter.package_name }}', '__main__.py'))
5438
os.unlink(join('src', '{{ cookiecutter.package_name }}', 'cli.py'))
@@ -80,19 +64,32 @@ def replace_contents(filename, what, replacement):
8064
os.unlink(join('ci', 'appveyor-bootstrap.py'))
8165
os.unlink(join('ci', 'appveyor-download.py'))
8266
os.unlink(join('ci', 'appveyor-with-compiler.cmd'))
83-
os.unlink('appveyor.yml')
84-
if os.path.exists(join('ci', 'templates', 'appveyor.yml')):
85-
os.unlink(join('ci', 'templates', 'appveyor.yml'))
67+
os.unlink(join('ci', 'templates', 'appveyor.yml'))
68+
if os.path.exists('appveyor.yml'):
69+
os.unlink('appveyor.yml')
8670
{% endif %}
8771

8872
{%- if cookiecutter.travis == 'no' %}
89-
os.unlink('.travis.yml')
90-
if os.path.exists(join('ci', 'templates', '.travis.yml')):
91-
os.unlink(join('ci', 'templates', '.travis.yml'))
73+
os.unlink(join('ci', 'templates', '.travis.yml'))
74+
if os.path.exists('.travis.yml'):
75+
os.unlink('.travis.yml')
9276
{% endif %}
9377

9478
print("""
9579
################################################################################
80+
81+
Generating CI configuration ...
82+
""")
83+
try:
84+
subprocess.check_call(['tox', '-e', 'bootstrap'])
85+
except Exception:
86+
try:
87+
subprocess.check_call([sys.executable, '-mtox', '-e', 'bootstrap'])
88+
except Exception:
89+
subprocess.check_call([sys.executable, join('ci', 'bootstrap.py')])
90+
91+
print("""
92+
################################################################################
9693
################################################################################
9794
9895
You have succesfully created `{{ cookiecutter.repo_name }}`.
@@ -104,6 +101,8 @@ def replace_contents(filename, what, replacement):
104101
{{ "{0:26}".format(key + ":") }} {{ "{0!r}".format(value).strip("u") }}
105102
{%- endfor %}
106103
104+
See .cookiecutterrc for instructions on regenerating the project.
105+
107106
################################################################################
108107
109108
To get started run these:
@@ -116,17 +115,16 @@ def replace_contents(filename, what, replacement):
116115
git push -u origin master
117116
118117
{% if cookiecutter.test_matrix_configurator == "yes" %}
119-
To reconfigure your test/CI settings run:
118+
To regenerate your tox.ini, .travis.yml or appveyor.yml run:
119+
{% else %}
120+
To regenerate your .travis.yml or appveyor.yml run:
121+
{% endif %}
120122
121123
tox -e bootstrap
122124
123125
You can also run:
124126
125127
./ci/bootstrap.py
126-
{% else %}
127-
The project doesn't use the test matrix configurator, but in case
128-
you change your mind just edit `setup.cfg` and run `ci/bootstrap.py`.
129-
{% endif %}
130128
""")
131129

132130
command_line_interface_bin_name = '{{ cookiecutter.command_line_interface_bin_name }}'

{{cookiecutter.repo_name}}/.travis.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

{{cookiecutter.repo_name}}/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Overview
6464
:alt: Code Quality Status
6565
{% endif %}
6666
{%- if cookiecutter.codacy == 'yes' %}
67-
.. |codacy| image:: https://img.shields.io/codacy/REPLACE_WITH_PROJECT_ID.svg
67+
.. |codacy| image:: https://img.shields.io/codacy/grade/{{ cookiecutter.codacy_projectid }}.svg
6868
:target: https://www.codacy.com/app/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}
6969
:alt: Codacy Code Quality Status
7070
{% endif %}

{{cookiecutter.repo_name}}/appveyor.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

{{cookiecutter.repo_name}}/ci/bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# WARNING: 'tox' must be installed globally or in the project's virtualenv
6666
for line in subprocess.check_output(['tox', '--listenvs'], universal_newlines=True).splitlines()
6767
]
68-
tox_environments = [line for line in tox_environments if line not in ['clean', 'report', 'docs', 'check']]
68+
tox_environments = [line for line in tox_environments if line.startswith('py')]
6969
{% endif %}
7070
for name in os.listdir(join("ci", "templates")):
7171
with open(join(base_path, name), "w") as fh:

{{cookiecutter.repo_name}}/ci/templates/.travis.yml

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,38 @@ matrix:
1515
- TOXENV=docs
1616
{%- endif %}
1717
{% if cookiecutter.test_matrix_configurator == "yes" -%}
18-
{% raw -%}
19-
{%- for env, config in tox_environments|dictsort %}{{ '' }}
20-
{% if env.startswith("pypy3") %}
21-
- python: 'pypy3.5-6.0'
22-
{% elif env.startswith("pypy") %}
23-
- python: 'pypy2.7-6.0'
24-
{% else %}
25-
- python: '{{ "{0[2]}.{0[3]}".format(env) }}'
26-
{% endif %}
27-
env:
28-
- TOXENV={{ env }}{% if config.cover %},report{% endraw %}
29-
{%- if cookiecutter.coveralls == 'yes' -%}
30-
{%- if cookiecutter.c_extension_support != "no" %},extension-coveralls{% endif %},coveralls
31-
{%- endif -%}
32-
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif -%}
33-
{%- raw %}{% endif -%}
34-
{% endfor %}
35-
{%- endraw %}
36-
{% else %}
37-
{%- raw -%}
38-
{%- for env in tox_environments %}{{ '' }}
39-
{% if env.startswith("pypy3") %}
40-
- python: 'pypy3.5-6.0'
41-
{% elif env.startswith("pypy") %}
42-
- python: 'pypy2.7-6.0'
43-
{% else %}
44-
- python: '{{ "{0[2]}.{0[3]}".format(env) }}'
45-
{% endif %}
46-
env:
47-
- TOXENV={{ env }}{% endraw -%}
48-
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}{% raw -%}
49-
{% if 'cover' in env %},report{% endraw %}
50-
{%- if cookiecutter.coveralls == 'yes' -%}
51-
{%- if cookiecutter.c_extension_support != "no" %},extension-coveralls{% endif %},coveralls
52-
{%- endif -%}
53-
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif -%}
54-
{%- raw %}{% endif -%}{% endraw %}
55-
{%- else %},report
56-
{%- if cookiecutter.coveralls == 'yes' %}
57-
{%- if cookiecutter.c_extension_support != "no" %},extension-coveralls{% endif %},coveralls
58-
{%- endif %}
59-
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif %}
60-
{%- endif %}
61-
{%- raw %}
62-
{%- endfor %}{{ '' }}
63-
{%- endraw %}
18+
{{ "{%- for env, config in tox_environments|dictsort %}{{ '' }}" }}
19+
{%- else -%}
20+
{{ "{%- for env in tox_environments %}{{ '' }}" }}
21+
{%- endif %}
22+
- env:
23+
- TOXENV={{ "{{ env }}" }}
24+
{%- if cookiecutter.test_matrix_configurator == "yes" -%}
25+
{{ "{% if config.cover %}" }}
26+
{%- else %}
27+
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}{{ "{% if 'cover' in env %}" }}{% endif %}
28+
{%- endif %}
29+
{%- if cookiecutter.coveralls == 'yes' %}
30+
{%- if cookiecutter.c_extension_support != "no" %},extension-coveralls{% endif -%}
31+
,coveralls
32+
{%- endif %}
33+
{%- if cookiecutter.codecov == 'yes' -%}
34+
,codecov
35+
{%- endif %}
36+
{%- if cookiecutter.test_matrix_configurator == "yes" -%}
37+
{{ "{% endif %}" }}
38+
{%- else %}
39+
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' -%}{{ "{% endif %}" }}{%- endif %}
6440
{%- endif %}
41+
{{ "{%- if env.startswith('pypy3') %}{{ '' }}" }}
42+
- TOXPYTHON=pypy3
43+
python: 'pypy3.5-6.0'
44+
{{ "{%- elif env.startswith('pypy') %}{{ '' }}" }}
45+
python: 'pypy2.7-6.0'
46+
{{ "{%- else %}{{ '' }}" }}
47+
python: {{ "'{{ '{0[2]}.{0[3]}'.format(env) }}'" }}
48+
{{ "{%- endif %}" }}
49+
{{ "{%- endfor %}{{ '' }}" }}
6550
before_install:
6651
- python --version
6752
- uname -a

0 commit comments

Comments
 (0)