Skip to content

Commit 599a917

Browse files
authored
Merge 17ac7d7 into b42fe01
2 parents b42fe01 + 17ac7d7 commit 599a917

30 files changed

+370
-58
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Provide a description and/or bullet points to describe the changes in this PR.
66

77
- [ ] Reference issues which can be closed due to this PR with "Closes #x".
88
- [ ] Review whether the documentation needs to be updated.
9-
- [ ] Document PR in CHANGES.rst.
9+
- [ ] Document PR in docs/changes.rst.

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ repos:
9494
rev: v1.0.1
9595
hooks:
9696
- id: tryceratops
97+
exclude: "{{cookiecutter.project_slug}}/pyproject.toml"
9798
- repo: https://github.com/pre-commit/mirrors-mypy
9899
rev: 'v0.931'
99100
hooks:

README.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cookiecutter-pytask-project
33

44
.. image:: https://img.shields.io/github/license/pytask-dev/cookiecutter-pytask-project
55
:alt: MIT license
6-
:target: https://pypi.org/project/pytask
6+
:target: https://github.com/pytask-dev/cookiecutter-pytask-project
77

88
.. image:: https://readthedocs.org/projects/cookiecutter-pytask-project/badge/?version=latest
99
:target: https://cookiecutter-pytask-project.readthedocs.io/en/latest
@@ -53,4 +53,7 @@ A: This is called the src layout and the advantages are discussed in this `artic
5353
Hynek Schlawack <https://hynek.me/articles/testing-packaging/>`_.
5454

5555
Although the article discusses the src layout in terms of Python packages, it is also
56-
beneficial to structure a project the same way.
56+
beneficial to structure a project the same way. Next to the reasons discussed there, it
57+
is possible to use a single Python environment for multiple projects without messing
58+
with your PYTHONPATH (via ``pip install -e .`` or ``conda develop .``) each time and
59+
still import modules.

cookiecutter.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
22
"author": "Arianna W. Rosenbluth",
3-
"email": "{{ cookiecutter.author.lower().replace(' ', '') }}@mail.edu",
3+
"email": "{{ cookiecutter.author.lower().replace(' ', '') }}@nowhere.edu",
44
"project_name": "Reproducible Research Template",
55
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
66
"project_description": "A project for ...",
77
"github_username": "{{ cookiecutter.author.lower().replace(' ', '') }}",
88
"github_email": "{{ cookiecutter.email }}",
9-
"version": "0.0.1",
109
"python_version": "3.8",
1110
"add_tox": ["yes", "no"],
1211
"add_github_actions": ["yes", "no"],
1312
"add_mypy": ["yes", "no"],
1413
"add_readthedocs": ["yes", "no"],
1514
"add_codecov": ["yes", "no"],
16-
"create_changelog": ["yes", "no"],
1715
"open_source_license": [
18-
"MIT", "BSD", "ISC", "Apache Software License 2.0",
19-
"GNU General Public License v3", "Not open source"
16+
"MIT",
17+
"BSD",
18+
"ISC",
19+
"Apache Software License 2.0",
20+
"GNU General Public License v3",
21+
"Not open source"
2022
],
2123
"make_initial_commit": ["no", "yes"],
2224
"conda_environment_name": "{{ cookiecutter.project_slug }}",
2325
"create_conda_environment_at_finish": ["no", "yes"],
24-
"_copy_without_render": [
25-
".github/workflows/main.yml"
26-
]
26+
"_copy_without_render": [".github/workflows/main.yml"]
2727
}

docs/rtd_environment.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44

55
dependencies:
66
- python >= 3.7
7-
- pip
7+
- pip >=21.1
88
- setuptools_scm
99
- toml
1010

@@ -14,6 +14,8 @@ dependencies:
1414
- nbsphinx
1515
- sphinx
1616
- sphinx-autoapi
17-
- sphinx-click
1817
- sphinx-copybutton
1918
- sphinx-panels
19+
20+
- pip:
21+
- -e ../

docs/source/api.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
API Reference
2+
=============
3+
4+
The following documents are auto-generated and not carefully edited. They provide direct
5+
access to the source code and the docstrings.
6+
7+
.. toctree::
8+
:titlesonly:
9+
10+
/autoapi/pre_gen_project/index
11+
/autoapi/post_gen_project/index

CHANGES.rst renamed to docs/source/changes.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Changes
44
This is a record of all past cookiecutter-pytask-project releases and what went into
55
them in reverse chronological order.
66

7+
1.2.0 - 2022-xx-xx
8+
------------------
9+
10+
- :gh:`7` skips concurrent CI builds.
11+
- :gh:`8` harmonizes cookiecutter-pytask-project with econ-project-templates.
12+
- :gh:`9` deprecates Python 3.6, add support for Python 3.10 and add mypy optionally.
13+
714

815
1.1.0 - 2022-01-16
916
------------------
@@ -13,7 +20,7 @@ them in reverse chronological order.
1320
remove unnecessary packaging stuff.
1421

1522

16-
1.0.0 - 2021-01-05
23+
1.0.0 - 2022-01-05
1724
------------------
1825

1926
- :gh:`1` creates first release of a minimal cookiecutter template for a pytask project.

docs/source/conf.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html
55
66
"""
7+
from importlib.metadata import version
8+
9+
710
# -- Project information -----------------------------------------------------
811

912

@@ -12,24 +15,58 @@
1215
copyright = f"2021, {author}" # noqa: A001
1316

1417
# The version, including alpha/beta/rc tags, but not commit hash and datestamps
15-
release = "1.1.0"
18+
release = version("cookiecutter-pytask-project")
1619
# The short X.Y version.
17-
version = "1.1"
20+
version = ".".join(release.split(".")[:2])
1821

1922

2023
# -- General configuration ---------------------------------------------------
2124

2225
# Add any Sphinx extension module names here, as strings. They can be extensions coming
2326
# with Sphinx (named 'sphinx.ext.*') or your custom ones.
24-
extensions = []
27+
extensions = [
28+
"IPython.sphinxext.ipython_console_highlighting",
29+
"IPython.sphinxext.ipython_directive",
30+
"sphinx.ext.autodoc",
31+
"sphinx.ext.autosummary",
32+
"sphinx.ext.extlinks",
33+
"sphinx.ext.intersphinx",
34+
"sphinx.ext.napoleon",
35+
"sphinx.ext.viewcode",
36+
"sphinx_copybutton",
37+
"sphinx_panels",
38+
"autoapi.extension",
39+
]
2540

2641
# Add any paths that contain templates here, relative to this directory.
2742
templates_path = ["_templates"]
2843

2944
# List of patterns, relative to source directory, that match files and directories to
3045
# ignore when looking for source files. This pattern also affects html_static_path and
3146
# html_extra_path.
32-
exclude_patterns = []
47+
exclude_patterns = ["build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
48+
49+
# Configuration for autoapi to generate and API page.
50+
autoapi_type = "python"
51+
autoapi_dirs = ["../../hooks"]
52+
autoapi_keep_files = False
53+
autoapi_add_toctree_entry = False
54+
55+
# Remove prefixed $ for bash, >>> for Python prompts, and In [1]: for IPython prompts.
56+
copybutton_prompt_text = r"\$ |>>> |In \[\d\]: "
57+
copybutton_prompt_is_regexp = True
58+
59+
# Use these roles to create links to github users and pull requests.
60+
extlinks = {
61+
"ghuser": ("https://github.com/%s", "@"),
62+
"gh": ("https://github.com/pytask-dev/cookiecutter-pytask-project/pull/%s", "#"),
63+
}
64+
65+
# Link objects to other documentations.
66+
intersphinx_mapping = {
67+
"python": ("https://docs.python.org/3.9", None),
68+
"pytask": ("https://pytask-dev.readthedocs.io/en/stable/", None),
69+
}
3370

3471

3572
# -- Options for HTML output -------------------------------------------------
@@ -38,6 +75,9 @@
3875
# builtin themes.
3976
html_theme = "furo"
4077

78+
pygments_style = "sphinx"
79+
pygments_dark_style = "monokai"
80+
4181
# Add any paths that contain custom static files (such as style sheets) here, relative
4282
# to this directory. They are copied after the builtin static files, so a file named
4383
# "default.css" will overwrite the builtin "default.css".

docs/source/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@ Welcome to cookiecutter-pytask-project's documentation!
22
=======================================================
33

44
.. include:: ../../README.rst
5+
6+
7+
.. toctree::
8+
:caption: Contents:
9+
:maxdepth: 1
10+
11+
changes
12+
api

environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ channels:
66

77
dependencies:
88
- python >=3.7
9-
- pip
9+
- pip >=21.1
1010
- setuptools_scm
1111
- toml
1212

@@ -16,6 +16,7 @@ dependencies:
1616

1717
# Misc
1818
- black
19+
- ipython
1920
- mypy
2021
- pre-commit
2122
- pytest

hooks/post_gen_project.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
"""This module contains hooks which are executed after the template is rendered."""
2+
from __future__ import annotations
3+
24
import shutil
35
import subprocess
46
import warnings
57
from pathlib import Path
68

79

8-
def remove_file(*filepath):
10+
def remove_file(*filepath: str | Path) -> None:
911
"""Remove a file."""
1012
try:
1113
Path(*filepath).unlink()
1214
except FileNotFoundError:
1315
pass
1416

1517

16-
def remove_directory(*filepath):
18+
def remove_directory(*filepath: str | Path) -> None:
1719
"""Remove a directory."""
1820
try:
1921
path = Path(*filepath)
@@ -22,13 +24,10 @@ def remove_directory(*filepath):
2224
pass
2325

2426

25-
def main():
27+
def main() -> None:
2628
"""Apply post generation hooks."""
2729
project_path = Path.cwd()
2830

29-
if "{{ cookiecutter.create_changelog }}" == "no":
30-
remove_file(project_path, "CHANGES.rst")
31-
3231
if "{{ cookiecutter.open_source_license }}" == "Not open source":
3332
remove_file(project_path, "LICENSE")
3433

hooks/pre_gen_project.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
"""This module contains hooks which are executed before the template is rendered."""
22
import re
33

4-
MODULE_REGEX = r"^[-_a-zA-Z0-9]*$"
4+
MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]*$"
55
ENVIRON_REGEX = r"^[-_a-zA-Z0-9]*$"
66
PYTHONVERSION_REGEX = r"^(3\.(10|[7-9])(\.[0-9]{1,2})?)$"
7+
PYTHONVERSION_MIN = "3.7"
78

89
EXCEPTION_MSG_MODULE_NAME = """
910
ERROR: The project slug ({module_name}) is not a valid Python module name.
10-
Please do not use anything other than letters, numbers, underscores '_',
11-
and minus signs '-'.
11+
12+
Please do not use anything other than letters, numbers, and underscores '_'.
13+
The first character must not be a number.
1214
"""
1315

1416
EXCEPTION_MSG_ENVIRON_NAME = """
1517
ERROR: The project slug ({environment_name}) is not a valid conda environment name.
18+
1619
Please do not use anything other than letters, numbers, underscores '_',
1720
and minus signs '-'.
1821
"""
1922

23+
EXCEPTION_MSG_PYTHONVERSION = """
24+
ERROR: The python version must be >= {PYTHONVERSION_MIN}, got {pythonversion}.
25+
"""
26+
2027

21-
def main():
28+
def main() -> None:
2229
"""Apply pre-generation hooks."""
2330
module_name = "{{ cookiecutter.project_slug}}"
2431

@@ -33,7 +40,9 @@ def main():
3340
python_version = "{{ cookiecutter.python_version }}"
3441

3542
if not re.match(PYTHONVERSION_REGEX, python_version):
36-
raise ValueError("ERROR: The python version must be >= 3.7") # noqa: TC003
43+
raise ValueError(
44+
EXCEPTION_MSG_PYTHONVERSION.format(PYTHONVERSION_MIN, python_version)
45+
)
3746

3847

3948
if __name__ == "__main__":

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
3+
4+
5+
[tool.setuptools_scm]
6+
write_to = "version.py"
7+
8+
19
[tool.tryceratops]
210
ignore = ["TC003"]
311

412

513
[tool.mypy]
6-
files = ["{{cookiecutter.project_slug}}", "tests"]
7-
exclude = "{{cookiecutter.project_slug}}/tests"
14+
files = ["hooks", "tests"]
15+
exclude = "{{cookiecutter.project_slug}}"
816
check_untyped_defs = true
917
disallow_any_generics = true
1018
disallow_incomplete_defs = true

setup.cfg

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[metadata]
2+
name = cookiecutter-pytask-project
3+
description = A minimal cookiecutter template for a project with pytask.
4+
long_description = file: README.rst
5+
long_description_content_type = text/x-rst
6+
url = https://cookiecutter-pytask-project.readthedocs.io/en/latest
7+
author = Tobias Raabe
8+
author_email = [email protected]
9+
license = MIT
10+
license_file = LICENSE
11+
platforms = unix, linux, osx, cygwin, win32
12+
classifiers =
13+
Development Status :: 3 - Alpha
14+
Environment :: Console
15+
Intended Audience :: Science/Research
16+
License :: OSI Approved :: MIT License
17+
Operating System :: MacOS :: MacOS X
18+
Operating System :: Microsoft :: Windows
19+
Operating System :: POSIX
20+
Programming Language :: Python :: 3
21+
Programming Language :: Python :: 3 :: Only
22+
Programming Language :: Python :: 3.7
23+
Programming Language :: Python :: 3.8
24+
Programming Language :: Python :: 3.9
25+
Programming Language :: Python :: 3.10
26+
Topic :: Scientific/Engineering
27+
Topic :: Software Development :: Build Tools
28+
project_urls =
29+
Changelog = https://cookiecutter-pytask-project.readthedocs.io/en/latest/changes.html
30+
Documentation = https://cookiecutter-pytask-project.readthedocs.io/en/latest
31+
Github = https://github.com/pytask-dev/cookiecutter-pytask-project
32+
Tracker = https://github.com/pytask-dev/cookiecutter-pytask-project/issues
33+
34+
35+
[check-manifest]
36+
ignore =
37+
version.py

0 commit comments

Comments
 (0)