diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 1414294..1817a2f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,4 +6,4 @@ Provide a description and/or bullet points to describe the changes in this PR. - [ ] Reference issues which can be closed due to this PR with "Closes #x". - [ ] Review whether the documentation needs to be updated. -- [ ] Document PR in CHANGES.rst. +- [ ] Document PR in docs/changes.rst. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 801f3a1..3aa1dc6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -94,6 +94,7 @@ repos: rev: v1.0.1 hooks: - id: tryceratops + exclude: "{{cookiecutter.project_slug}}/pyproject.toml" - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v0.931' hooks: diff --git a/README.rst b/README.rst index 1c0c833..9ea89a9 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ cookiecutter-pytask-project .. image:: https://img.shields.io/github/license/pytask-dev/cookiecutter-pytask-project :alt: MIT license - :target: https://pypi.org/project/pytask + :target: https://github.com/pytask-dev/cookiecutter-pytask-project .. image:: https://readthedocs.org/projects/cookiecutter-pytask-project/badge/?version=latest :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 Hynek Schlawack `_. Although the article discusses the src layout in terms of Python packages, it is also -beneficial to structure a project the same way. +beneficial to structure a project the same way. Next to the reasons discussed there, it +is possible to use a single Python environment for multiple projects without messing +with your PYTHONPATH (via ``pip install -e .`` or ``conda develop .``) each time and +still import modules. diff --git a/cookiecutter.json b/cookiecutter.json index 5d61e27..331cfb7 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,27 +1,27 @@ { "author": "Arianna W. Rosenbluth", - "email": "{{ cookiecutter.author.lower().replace(' ', '') }}@mail.edu", + "email": "{{ cookiecutter.author.lower().replace(' ', '') }}@nowhere.edu", "project_name": "Reproducible Research Template", "project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}", "project_description": "A project for ...", "github_username": "{{ cookiecutter.author.lower().replace(' ', '') }}", "github_email": "{{ cookiecutter.email }}", - "version": "0.0.1", "python_version": "3.8", "add_tox": ["yes", "no"], "add_github_actions": ["yes", "no"], "add_mypy": ["yes", "no"], "add_readthedocs": ["yes", "no"], "add_codecov": ["yes", "no"], - "create_changelog": ["yes", "no"], "open_source_license": [ - "MIT", "BSD", "ISC", "Apache Software License 2.0", - "GNU General Public License v3", "Not open source" + "MIT", + "BSD", + "ISC", + "Apache Software License 2.0", + "GNU General Public License v3", + "Not open source" ], "make_initial_commit": ["no", "yes"], "conda_environment_name": "{{ cookiecutter.project_slug }}", "create_conda_environment_at_finish": ["no", "yes"], - "_copy_without_render": [ - ".github/workflows/main.yml" - ] + "_copy_without_render": [".github/workflows/main.yml"] } diff --git a/docs/rtd_environment.yml b/docs/rtd_environment.yml index 1867ea9..25d3cc0 100644 --- a/docs/rtd_environment.yml +++ b/docs/rtd_environment.yml @@ -4,7 +4,7 @@ channels: dependencies: - python >= 3.7 - - pip + - pip >=21.1 - setuptools_scm - toml @@ -14,6 +14,8 @@ dependencies: - nbsphinx - sphinx - sphinx-autoapi - - sphinx-click - sphinx-copybutton - sphinx-panels + + - pip: + - -e ../ diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..d4b8ab8 --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,11 @@ +API Reference +============= + +The following documents are auto-generated and not carefully edited. They provide direct +access to the source code and the docstrings. + +.. toctree:: + :titlesonly: + + /autoapi/pre_gen_project/index + /autoapi/post_gen_project/index diff --git a/CHANGES.rst b/docs/source/changes.rst similarity index 66% rename from CHANGES.rst rename to docs/source/changes.rst index 745cd89..fb07568 100644 --- a/CHANGES.rst +++ b/docs/source/changes.rst @@ -4,6 +4,13 @@ Changes This is a record of all past cookiecutter-pytask-project releases and what went into them in reverse chronological order. +1.2.0 - 2022-xx-xx +------------------ + +- :gh:`7` skips concurrent CI builds. +- :gh:`8` harmonizes cookiecutter-pytask-project with econ-project-templates. +- :gh:`9` deprecates Python 3.6, add support for Python 3.10 and add mypy optionally. + 1.1.0 - 2022-01-16 ------------------ @@ -13,7 +20,7 @@ them in reverse chronological order. remove unnecessary packaging stuff. -1.0.0 - 2021-01-05 +1.0.0 - 2022-01-05 ------------------ - :gh:`1` creates first release of a minimal cookiecutter template for a pytask project. diff --git a/docs/source/conf.py b/docs/source/conf.py index 9bc4075..00ad227 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -4,6 +4,9 @@ documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html """ +from importlib.metadata import version + + # -- Project information ----------------------------------------------------- @@ -12,16 +15,28 @@ copyright = f"2021, {author}" # noqa: A001 # The version, including alpha/beta/rc tags, but not commit hash and datestamps -release = "1.1.0" +release = version("cookiecutter-pytask-project") # The short X.Y version. -version = "1.1" +version = ".".join(release.split(".")[:2]) # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions coming # with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] +extensions = [ + "IPython.sphinxext.ipython_console_highlighting", + "IPython.sphinxext.ipython_directive", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.extlinks", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "sphinx_copybutton", + "sphinx_panels", + "autoapi.extension", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -29,7 +44,29 @@ # List of patterns, relative to source directory, that match files and directories to # ignore when looking for source files. This pattern also affects html_static_path and # html_extra_path. -exclude_patterns = [] +exclude_patterns = ["build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"] + +# Configuration for autoapi to generate and API page. +autoapi_type = "python" +autoapi_dirs = ["../../hooks"] +autoapi_keep_files = False +autoapi_add_toctree_entry = False + +# Remove prefixed $ for bash, >>> for Python prompts, and In [1]: for IPython prompts. +copybutton_prompt_text = r"\$ |>>> |In \[\d\]: " +copybutton_prompt_is_regexp = True + +# Use these roles to create links to github users and pull requests. +extlinks = { + "ghuser": ("https://github.com/%s", "@"), + "gh": ("https://github.com/pytask-dev/cookiecutter-pytask-project/pull/%s", "#"), +} + +# Link objects to other documentations. +intersphinx_mapping = { + "python": ("https://docs.python.org/3.9", None), + "pytask": ("https://pytask-dev.readthedocs.io/en/stable/", None), +} # -- Options for HTML output ------------------------------------------------- @@ -38,6 +75,9 @@ # builtin themes. html_theme = "furo" +pygments_style = "sphinx" +pygments_dark_style = "monokai" + # Add any paths that contain custom static files (such as style sheets) here, relative # to this directory. They are copied after the builtin static files, so a file named # "default.css" will overwrite the builtin "default.css". diff --git a/docs/source/index.rst b/docs/source/index.rst index 669b16e..417add8 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,3 +2,11 @@ Welcome to cookiecutter-pytask-project's documentation! ======================================================= .. include:: ../../README.rst + + +.. toctree:: + :caption: Contents: + :maxdepth: 1 + + changes + api diff --git a/environment.yml b/environment.yml index 6b35fd3..34c6388 100644 --- a/environment.yml +++ b/environment.yml @@ -6,7 +6,7 @@ channels: dependencies: - python >=3.7 - - pip + - pip >=21.1 - setuptools_scm - toml @@ -16,6 +16,7 @@ dependencies: # Misc - black + - ipython - mypy - pre-commit - pytest diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 6cf1f89..65c591e 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1,11 +1,13 @@ """This module contains hooks which are executed after the template is rendered.""" +from __future__ import annotations + import shutil import subprocess import warnings from pathlib import Path -def remove_file(*filepath): +def remove_file(*filepath: str | Path) -> None: """Remove a file.""" try: Path(*filepath).unlink() @@ -13,7 +15,7 @@ def remove_file(*filepath): pass -def remove_directory(*filepath): +def remove_directory(*filepath: str | Path) -> None: """Remove a directory.""" try: path = Path(*filepath) @@ -22,13 +24,10 @@ def remove_directory(*filepath): pass -def main(): +def main() -> None: """Apply post generation hooks.""" project_path = Path.cwd() - if "{{ cookiecutter.create_changelog }}" == "no": - remove_file(project_path, "CHANGES.rst") - if "{{ cookiecutter.open_source_license }}" == "Not open source": remove_file(project_path, "LICENSE") diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 04e566f..c0da4dc 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -1,24 +1,31 @@ """This module contains hooks which are executed before the template is rendered.""" import re -MODULE_REGEX = r"^[-_a-zA-Z0-9]*$" +MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]*$" ENVIRON_REGEX = r"^[-_a-zA-Z0-9]*$" PYTHONVERSION_REGEX = r"^(3\.(10|[7-9])(\.[0-9]{1,2})?)$" +PYTHONVERSION_MIN = "3.7" EXCEPTION_MSG_MODULE_NAME = """ ERROR: The project slug ({module_name}) is not a valid Python module name. -Please do not use anything other than letters, numbers, underscores '_', -and minus signs '-'. + +Please do not use anything other than letters, numbers, and underscores '_'. +The first character must not be a number. """ EXCEPTION_MSG_ENVIRON_NAME = """ ERROR: The project slug ({environment_name}) is not a valid conda environment name. + Please do not use anything other than letters, numbers, underscores '_', and minus signs '-'. """ +EXCEPTION_MSG_PYTHONVERSION = """ +ERROR: The python version must be >= {PYTHONVERSION_MIN}, got {pythonversion}. +""" + -def main(): +def main() -> None: """Apply pre-generation hooks.""" module_name = "{{ cookiecutter.project_slug}}" @@ -33,7 +40,9 @@ def main(): python_version = "{{ cookiecutter.python_version }}" if not re.match(PYTHONVERSION_REGEX, python_version): - raise ValueError("ERROR: The python version must be >= 3.7") # noqa: TC003 + raise ValueError( + EXCEPTION_MSG_PYTHONVERSION.format(PYTHONVERSION_MIN, python_version) + ) if __name__ == "__main__": diff --git a/pyproject.toml b/pyproject.toml index 7ff617a..cadab6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,18 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] + + +[tool.setuptools_scm] +write_to = "version.py" + + [tool.tryceratops] ignore = ["TC003"] [tool.mypy] -files = ["{{cookiecutter.project_slug}}", "tests"] -exclude = "{{cookiecutter.project_slug}}/tests" +files = ["hooks", "tests"] +exclude = "{{cookiecutter.project_slug}}" check_untyped_defs = true disallow_any_generics = true disallow_incomplete_defs = true diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..600ac9d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,37 @@ +[metadata] +name = cookiecutter-pytask-project +description = A minimal cookiecutter template for a project with pytask. +long_description = file: README.rst +long_description_content_type = text/x-rst +url = https://cookiecutter-pytask-project.readthedocs.io/en/latest +author = Tobias Raabe +author_email = raabe@posteo.de +license = MIT +license_file = LICENSE +platforms = unix, linux, osx, cygwin, win32 +classifiers = + Development Status :: 3 - Alpha + Environment :: Console + Intended Audience :: Science/Research + License :: OSI Approved :: MIT License + Operating System :: MacOS :: MacOS X + Operating System :: Microsoft :: Windows + Operating System :: POSIX + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Topic :: Scientific/Engineering + Topic :: Software Development :: Build Tools +project_urls = + Changelog = https://cookiecutter-pytask-project.readthedocs.io/en/latest/changes.html + Documentation = https://cookiecutter-pytask-project.readthedocs.io/en/latest + Github = https://github.com/pytask-dev/cookiecutter-pytask-project + Tracker = https://github.com/pytask-dev/cookiecutter-pytask-project/issues + + +[check-manifest] +ignore = + version.py diff --git a/tests/test_cookie.py b/tests/test_cookie.py index e4c99c2..93ba4f5 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -74,18 +74,6 @@ def test_remove_license(cookies): assert not license_.exists() -@pytest.mark.end_to_end -def test_remove_changes(cookies): - result = cookies.bake(extra_context={"create_changelog": "no"}) - - changes = result.project_path.joinpath("CHANGES.rst") - - assert result.exit_code == 0 - assert result.exception is None - - assert not changes.exists() - - @pytest.mark.end_to_end @pytest.mark.skipif(os.environ.get("CI") is None, reason="Run only in CI.") def test_check_conda_environment_creation_and_run_all_checks(cookies): @@ -119,3 +107,15 @@ def test_check_conda_environment_creation_and_run_all_checks(cookies): cwd=result.project_path, check=True, ) + + # Test building documentation + subprocess.run( + ("conda", "run", "-n", "__test__", "pip", "install", "-e", "."), + cwd=result.project_path, + check=True, + ) + subprocess.run( + ("conda", "run", "-n", "__test__", "make", "html"), + cwd=result.project_path / "docs", + check=True, + ) diff --git a/tox.ini b/tox.ini index 74971ca..2cc4f13 100644 --- a/tox.ini +++ b/tox.ini @@ -39,7 +39,7 @@ ignore-path = docs/build ignore-path-errors = {{cookiecutter.project_slug}}/README.rst;D000, - {{cookiecutter.project_slug}}/CHANGES.rst;D000 + {{cookiecutter.project_slug}}/docs/source/changes.rst;D000 max-line-length = 88 [flake8] diff --git a/{{cookiecutter.project_slug}}/.github/pull_request_template.md b/{{cookiecutter.project_slug}}/.github/pull_request_template.md index 1414294..1817a2f 100644 --- a/{{cookiecutter.project_slug}}/.github/pull_request_template.md +++ b/{{cookiecutter.project_slug}}/.github/pull_request_template.md @@ -6,4 +6,4 @@ Provide a description and/or bullet points to describe the changes in this PR. - [ ] Reference issues which can be closed due to this PR with "Closes #x". - [ ] Review whether the documentation needs to be updated. -- [ ] Document PR in CHANGES.rst. +- [ ] Document PR in docs/changes.rst. diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml index ea94885..fd20f94 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Continuous Integration Workflow +name: main # Automatically cancel a previous run. concurrency: diff --git a/{{cookiecutter.project_slug}}/docs/Makefile b/{{cookiecutter.project_slug}}/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/{{cookiecutter.project_slug}}/docs/make.bat b/{{cookiecutter.project_slug}}/docs/make.bat new file mode 100644 index 0000000..061f32f --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/{{cookiecutter.project_slug}}/docs/rtd_environment.yml b/{{cookiecutter.project_slug}}/docs/rtd_environment.yml new file mode 100644 index 0000000..e08570d --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/rtd_environment.yml @@ -0,0 +1,18 @@ +channels: + - conda-forge + - nodefaults + +dependencies: + - python >= 3.7 + - pip + - setuptools_scm + - toml + + # Documentation + - furo + - ipython + - nbsphinx + - sphinx + - sphinx-autoapi + - sphinx-copybutton + - sphinx-panels diff --git a/{{cookiecutter.project_slug}}/docs/source/api.rst b/{{cookiecutter.project_slug}}/docs/source/api.rst new file mode 100644 index 0000000..536d855 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/api.rst @@ -0,0 +1,10 @@ +API Reference +============= + +The following documents are auto-generated and not carefully edited. They provide direct +access to the source code and the docstrings. + +.. toctree:: + :titlesonly: + + /autoapi/{{ cookiecutter.project_slug }}/index diff --git a/{{cookiecutter.project_slug}}/CHANGES.rst b/{{cookiecutter.project_slug}}/docs/source/changes.rst similarity index 100% rename from {{cookiecutter.project_slug}}/CHANGES.rst rename to {{cookiecutter.project_slug}}/docs/source/changes.rst diff --git a/{{cookiecutter.project_slug}}/docs/source/conf.py b/{{cookiecutter.project_slug}}/docs/source/conf.py new file mode 100644 index 0000000..dd35d4c --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/conf.py @@ -0,0 +1,87 @@ +"""Configuration file for the Sphinx documentation builder. + +This file only contains a selection of the most common options. For a full list see the +documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html + +""" +from importlib.metadata import version + + +# -- Project information ----------------------------------------------------- + +project = "{{ cookiecutter.project_name }}" +author = "{{ cookiecutter.author }}" +copyright = f"2022, {author}" # noqa: A001 + +# The version, including alpha/beta/rc tags, but not commit hash and datestamps +release = version("{{ cookiecutter.project_slug }}") +# The short X.Y version. +version = ".".join(release.split(".")[:2]) + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions coming +# with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + "IPython.sphinxext.ipython_console_highlighting", + "IPython.sphinxext.ipython_directive", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.extlinks", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "sphinx_copybutton", + "sphinx_panels", + "autoapi.extension", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and directories to +# ignore when looking for source files. This pattern also affects html_static_path and +# html_extra_path. +exclude_patterns = ["build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"] + +# Configuration for autoapi to generate and API page. +autoapi_type = "python" +autoapi_dirs = ["../../src"] +autoapi_keep_files = False +autoapi_add_toctree_entry = False + +# Remove prefixed $ for bash, >>> for Python prompts, and In [1]: for IPython prompts. +copybutton_prompt_text = r"\$ |>>> |In \[\d\]: " +copybutton_prompt_is_regexp = True + +# Use these roles to create links to github users and pull requests. +extlinks = { + "ghuser": ("https://github.com/%s", "@"), + "gh": ( + "https://github.com/{{ cookiecutter.github_username }}/" + "{{ cookiecutter.project_slug }}/pull/%s", + "#", + ), +} + +# Link objects to other documentations. +intersphinx_mapping = { + "python": ("https://docs.python.org/3.9", None), + "pytask": ("https://pytask-dev.readthedocs.io/en/stable/", None), +} + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for a list of +# builtin themes. +html_theme = "furo" + +pygments_style = "sphinx" +pygments_dark_style = "monokai" + +# Add any paths that contain custom static files (such as style sheets) here, relative +# to this directory. They are copied after the builtin static files, so a file named +# "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] diff --git a/{{cookiecutter.project_slug}}/docs/source/index.rst b/{{cookiecutter.project_slug}}/docs/source/index.rst new file mode 100644 index 0000000..1317e3c --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/index.rst @@ -0,0 +1,9 @@ +Welcome to {{ cookiecutter.project_name }}'s documentation! +{% for _ in range(cookiecutter.project_name | length + 28) %}={% endfor %} + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + changes + api diff --git a/{{cookiecutter.project_slug}}/environment.yml b/{{cookiecutter.project_slug}}/environment.yml index 6a21a69..7320b2e 100644 --- a/{{cookiecutter.project_slug}}/environment.yml +++ b/{{cookiecutter.project_slug}}/environment.yml @@ -6,7 +6,7 @@ channels: dependencies: - python >=3.7 - - pip + - pip >=21.1 - setuptools_scm - toml @@ -18,6 +18,7 @@ dependencies: # Misc - black + - ipython - pre-commit - pytest - pytest-cov diff --git a/{{cookiecutter.project_slug}}/pytask.ini b/{{cookiecutter.project_slug}}/pytask.ini deleted file mode 100644 index 4a8e361..0000000 --- a/{{cookiecutter.project_slug}}/pytask.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytask] -paths = ./src/{{ cookiecutter.project_slug }} diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py new file mode 100644 index 0000000..075592e --- /dev/null +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py @@ -0,0 +1,11 @@ +"""This module contains the main namespace of {{ cookiecutter.project_slug }}.""" +# Import the version from _version.py which is dynamically created by setuptools-scm +# when the project is installed with ``pip install -e .``. Do not put it into version +# control! +try: + from ._version import version as __version__ +except ImportError: + __version__ = "unknown" + + +__all__ = ["__version__"] diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py index df50b41..cb77e44 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py @@ -2,14 +2,8 @@ from pathlib import Path -try: - from ._version import version as __version__ -except ImportError: - __version__ = "unknown" - - SRC = Path(__file__).parent.resolve() -BLD = SRC.joinpath("..", "..", "bld") +BLD = SRC.joinpath("..", "..", "bld").resolve() -__all__ = ["__version__", "BLD", "SRC"] +__all__ = ["BLD", "SRC"] diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index b9b8519..df14100 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -24,6 +24,9 @@ conda_deps = commands = pytest {posargs} +[pytask] +paths = ./src/{{ cookiecutter.project_slug }} + [doc8] ignore = D004 max-line-length = 88