From 84649ff8671de63a86b6f85c1884c3f4c887fecd Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:02:45 -0700 Subject: [PATCH 01/34] clean up the conf.py for building the docs --- .../docs/conf.py | 68 +------------------ 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py index b3e8ba4e..09a2d390 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# # {{ cookiecutter.package_name }} documentation build configuration file, created by # sphinx-quickstart on Fri Jun 9 13:47:02 2017. # @@ -18,10 +15,6 @@ # relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. # -import os -import sys -sys.path.insert(0, os.path.abspath('..')) - import {{ cookiecutter.package_name }} # -- General configuration --------------------------------------------- @@ -101,63 +94,4 @@ # -- Options for HTMLHelp output --------------------------------------- # Output file base name for HTML help builder. -htmlhelp_basename = '{{ cookiecutter.package_name }}doc' - - -# -- Options for LaTeX output ------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass -# [howto, manual, or own class]). -latex_documents = [ - (master_doc, '{{ cookiecutter.package_name }}.tex', - u'{{ cookiecutter.package_name }} Documentation', - u'{{ cookiecutter.info.full_name }}', 'manual'), -] - - -# -- Options for manual page output ------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, '{{ cookiecutter.package_name }}', - u'{{ cookiecutter.package_name }} Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, '{{ cookiecutter.package_name }}', - u'{{ cookiecutter.package_name }} Documentation', - author, - '{{ cookiecutter.package_name }}', - 'One line description of project.', - 'Miscellaneous'), -] - - - +htmlhelp_basename = '{{ cookiecutter.package_name }}doc' \ No newline at end of file From c0fbea84f958d3d5dfcb888b2f88825289157ab9 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:03:42 -0700 Subject: [PATCH 02/34] move static metadata into pyproject.toml --- .../pyproject.toml | 64 +++++++ .../{{cookiecutter.package_name}}/setup.py | 168 +----------------- 2 files changed, 68 insertions(+), 164 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml index 80670bd5..06bcafca 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml +++ b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml @@ -1,6 +1,70 @@ [build-system] requires = ["cython", "numpy", "setuptools", "wheel"] +[project] +name = "{{cookiecutter.package_name}}" +authors = [ + {name = "{{cookiecutter.info.full_name}}", email = "{{cookiecutter.info.email}}"}, +] +maintainers = [ + {name = "{{cookiecutter.info.full_name}}", email = "{{cookiecutter.info.email}}"}, +] +description = "PyMT plugin for {{cookiecutter.package_name}}" +license = {text = "MIT License"} +classifiers=[ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: {{ cookiecutter.open_source_license }}", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", +] +requires-python = ">=3.8" +keywords=["bmi", "pymt"] +dynamic = ["readme", "version"] +dependencies = [ + "numpy", +] + +[project.urls] +homepage = "https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }}" + +[project.entry-points."pymt.plugins"] +{%- for babelized_class, _ in cookiecutter.components|dictsort %} +{{ babelized_class }} = "{{ cookiecutter.package_name }}.bmi:{{ babelized_class }}" +{%- endfor %} + +[project.optional-dependencies] +dev = [ + "nox", +] +docs = [ + "sphinx>=4", + "sphinx-copybutton", + "sphinx-inline-tabs", + "sphinxcontrib.towncrier", + "pygments>=2.4", + "sphinx-inline-tabs", + "furo", +] +testing = [ + "bmi-tester>=0.5.4", +] + +[tool.setuptools.dynamic] +readme = {file = ["README.rst", "CREDITS.rst", "CHANGES.rst", "LICENSE"]} +version = {attr = "{{ cookiecutter.package_name }}._version.__version__"} + +[tool.setuptools] +include-package-data = true +packages = ["{{ cookiecutter.package_name }}"] + +[tool.setuptools.package-data] +{{ cookiecutter.package_name }} = [ + "data/*", +] + [tool.pytest.ini_options] minversion = "5.0" testpaths = ["{{ cookiecutter.package_name }}", "tests"] diff --git a/babelizer/data/{{cookiecutter.package_name}}/setup.py b/babelizer/data/{{cookiecutter.package_name}}/setup.py index b58eae5e..76102434 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/setup.py +++ b/babelizer/data/{{cookiecutter.package_name}}/setup.py @@ -1,174 +1,14 @@ -#! /usr/bin/env python -import os -import sys -{%- if cookiecutter.language == 'fortran' %} -import contextlib -import subprocess -{%- endif -%} +from setuptools import setup {%- if cookiecutter.language in ['c', 'c++', 'fortran'] %} -import numpy as np -{% endif %} -from setuptools import Extension, find_packages, setup - -{% if cookiecutter.language == 'fortran' -%} -from setuptools.command.build_ext import build_ext as _build_ext -from numpy.distutils.fcompiler import new_fcompiler +from setup_utils import build_ext, get_extension_modules {% endif %} -{% if cookiecutter.language in ['c', 'c++', 'fortran'] -%} -common_flags = { - "include_dirs": [ - np.get_include(), - os.path.join(sys.prefix, "include"), - {%- for dir in cookiecutter.build.include_dirs %} - "{{ dir|trim }}", - {% endfor %} - ], - "library_dirs": [ - {%- for libdir in cookiecutter.build.library_dirs %} - "{{ libdir|trim }}", - {% endfor %} - ], - "define_macros": [ - {%- if cookiecutter.build.define_macros -%} - {%- for item in cookiecutter.build.define_macros %} - {%- set key_value = item.split('=') %} - ("{{ key_value[0]|trim }}", "{{ key_value[1]|trim }}"),{% endfor %} - {%- endif %} - ], - "undef_macros": [ - {%- if cookiecutter.build.undef_macros -%} - {%- for macro in cookiecutter.build.undef_macros %} - "{{ macro|trim }}",{% endfor %} - {%- endif %} - ], - "extra_compile_args": [ - {%- if cookiecutter.build.extra_compile_args -%} - {%- for arg in cookiecutter.build.extra_compile_args %} - "{{ arg|trim }}",{% endfor %} - {%- endif %} - ], -{%- if cookiecutter.language == 'fortran' %} - "language": "c", -{% else %} - "language": "{{ cookiecutter.language }}", -{% endif -%} -} - -libraries = [ -{%- if cookiecutter.build.libraries -%} -{%- for lib in cookiecutter.build.libraries %} - "{{ lib|trim }}",{% endfor %} -{%- endif %} -] - -# Locate directories under Windows %LIBRARY_PREFIX%. -if sys.platform.startswith("win"): - common_flags["include_dirs"].append(os.path.join(sys.prefix, "Library", "include")) - common_flags["library_dirs"].append(os.path.join(sys.prefix, "Library", "lib")) - -ext_modules = [ -{%- for babelized_class, component in cookiecutter.components|dictsort %} - Extension( - "{{cookiecutter.package_name}}.lib.{{ babelized_class|lower }}", - ["{{cookiecutter.package_name}}/lib/{{ babelized_class|lower }}.pyx"], - libraries=libraries + ["{{ component.library }}"], - {% if cookiecutter.language == 'fortran' -%} - extra_objects=['{{cookiecutter.package_name}}/lib/bmi_interoperability.o'], - {% endif -%} - **common_flags - ), -{%- endfor %} -] - -{%- endif %} - -entry_points = { - "pymt.plugins": [ -{%- for babelized_class, _ in cookiecutter.components|dictsort %} - "{{ babelized_class }}={{ cookiecutter.package_name }}.bmi:{{ babelized_class }}", -{%- endfor %} - ] -} - -{% if cookiecutter.language == 'fortran' %} -@contextlib.contextmanager -def as_cwd(path): - prev_cwd = os.getcwd() - os.chdir(path) - yield - os.chdir(prev_cwd) - - -def build_interoperability(): - compiler = new_fcompiler() - compiler.customize() - - cmd = [] - cmd.append(compiler.compiler_f90[0]) - cmd.append(compiler.compile_switch) - if sys.platform.startswith("win") is False: - cmd.append("-fPIC") - for include_dir in common_flags['include_dirs']: - if os.path.isabs(include_dir) is False: - include_dir = os.path.join(sys.prefix, "include", include_dir) - cmd.append('-I{}'.format(include_dir)) - cmd.append('bmi_interoperability.f90') - - try: - subprocess.check_call(cmd) - except subprocess.CalledProcessError: - raise - - -class build_ext(_build_ext): - - def run(self): - with as_cwd('{{cookiecutter.package_name}}/lib'): - build_interoperability() - _build_ext.run(self) - -{% endif -%} - - -def read(filename): - with open(filename, "r", encoding="utf-8") as fp: - return fp.read() - - -long_description = u'\n\n'.join( - [read('README.rst'), read('CREDITS.rst'), read('CHANGES.rst')] -) - - setup( - name="{{cookiecutter.package_name}}", - author="{{cookiecutter.info.full_name}}", - author_email="{{cookiecutter.info.email}}", - description="PyMT plugin for {{cookiecutter.package_name}}", - long_description=long_description, - version="{{cookiecutter.package_version}}", - url="https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }}", - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: {{ cookiecutter.open_source_license }}", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - ], - keywords=["bmi", "pymt"], - install_requires=open("requirements.txt", "r").read().splitlines(), {%- if cookiecutter.language in ['c', 'c++', 'fortran'] %} - setup_requires=["cython"], - ext_modules=ext_modules, + ext_modules=get_extension_modules(), {%- endif %} {%- if cookiecutter.language == 'fortran' %} - cmdclass=dict(build_ext=build_ext), + cmdclass={"build_ext": build_ext}, {%- endif %} - packages=find_packages(), - entry_points=entry_points, - include_package_data=True, ) From 75fe27d831a003c5444d8241b71b2da0ada6b4d2 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:48:58 -0700 Subject: [PATCH 03/34] set docs language to "en" --- babelizer/data/{{cookiecutter.package_name}}/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py index 804c04e8..daa0f150 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py @@ -58,7 +58,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 9f5361cc81cdc954ea55f7e682ad360853ddbda2 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:49:34 -0700 Subject: [PATCH 04/34] add .nox folder to gitignore --- babelizer/data/{{cookiecutter.package_name}}/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/babelizer/data/{{cookiecutter.package_name}}/.gitignore b/babelizer/data/{{cookiecutter.package_name}}/.gitignore index e67ffb7d..3b80cb7c 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/.gitignore +++ b/babelizer/data/{{cookiecutter.package_name}}/.gitignore @@ -100,6 +100,9 @@ ENV/ # mypy .mypy_cache/ +# nox virtual envs +.nox/ + {% if cookiecutter.language == 'fortran' -%} {%- for babelized_class in cookiecutter.components %} # Fortran files generated by the babelizer From d8d522f4313e39ad79e944fe1a396d5562d89978 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:50:19 -0700 Subject: [PATCH 05/34] remove the recipe folder --- .../recipe/meta.yaml | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 babelizer/data/{{cookiecutter.package_name}}/recipe/meta.yaml diff --git a/babelizer/data/{{cookiecutter.package_name}}/recipe/meta.yaml b/babelizer/data/{{cookiecutter.package_name}}/recipe/meta.yaml deleted file mode 100644 index 4302b926..00000000 --- a/babelizer/data/{{cookiecutter.package_name}}/recipe/meta.yaml +++ /dev/null @@ -1,55 +0,0 @@ -{{"{%"}} set data = load_setup_py_data() {{"%}"}} - -package: - name: "{{cookiecutter.package_name}}" - version: {{"{{"}} data.get('version') {{"}}"}} - -source: - path: .. - -build: - number: 0 - script: "{{"{{"}} PYTHON {{"}}"}} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv" - -requirements: - build: - - {{"{{"}} compiler('c') {{"}}"}} - {%- if cookiecutter.language == 'fortran' %} - - {{"{{"}} compiler('fortran') {{"}}"}} - {%- endif %} - host: - - python - - pip - - cython - - numpy 1.11.* - - model_metadata - {%- if cookiecutter.package_requirements -%} - {%- for requirement in cookiecutter.package_requirements.split(',') %} - - {{ requirement|trim }} {% endfor %} - {%- endif %} - run: - - python - - {{"{{"}} pin_compatible('numpy') {{"}}"}} - {%- if cookiecutter.package_requirements -%} - {%- for requirement in cookiecutter.package_requirements.split(',') %} - - {{ requirement|trim }} {% endfor %} - {%- endif %} - -test: - requires: - - bmi-tester - - model_metadata - imports: - - {{cookiecutter.package_name}} - commands: -{%- for babelized_class in cookiecutter.components %} - - config_file=$(mmd-stage {{ babelized_class }} . > MANIFEST && mmd-query {{ babelized_class }} --var=run.config_file.path) - - bmi-test {{ cookiecutter.package_name }}.bmi:{{ babelized_class }} --config-file=$config_file --manifest=MANIFEST -v -{%- endfor %} - -about: - summary: Python package that wraps the {{cookiecutter.package_name}} BMI. - home: https://github.com/{{cookiecutter.info.github_username}}/{{cookiecutter.package_name}} - license: {{cookiecutter.open_source_license}} - license_file: LICENSE - dev_url: https://github.com/{{cookiecutter.info.github_username}}/{{cookiecutter.package_name}} From e439d4962d9b07ed394f3dd4a10c80173057ffa7 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:51:03 -0700 Subject: [PATCH 06/34] make the bmi module private --- .../{{cookiecutter.package_name}}/__init__.py | 10 +++------- .../{{cookiecutter.package_name}}/{bmi.py => _bmi.py} | 2 -- babelizer/render.py | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) rename babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/{bmi.py => _bmi.py} (94%) diff --git a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/__init__.py b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/__init__.py index 7dcfe8be..3e09b95d 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/__init__.py +++ b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/__init__.py @@ -1,17 +1,13 @@ -#! /usr/bin/env python -import pkg_resources +from ._version import __version__ - -__version__ = pkg_resources.get_distribution("{{ cookiecutter.package_name }}").version - - -from .bmi import ( +from ._bmi import ( {%- for babelized_class, _ in cookiecutter.components|dictsort %} {{ babelized_class }}, {%- endfor %} ) __all__ = [ + "__version__", {%- for babelized_class, _ in cookiecutter.components|dictsort %} "{{ babelized_class }}", {%- endfor %} diff --git a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_bmi.py similarity index 94% rename from babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py rename to babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_bmi.py index a7026bc0..ca4f8044 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py +++ b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_bmi.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - {% set classes = [] -%} {%- for babelized_class in cookiecutter.components -%} {% set _ = classes.append(babelized_class) %} diff --git a/babelizer/render.py b/babelizer/render.py index 34f13919..afaa2e4a 100644 --- a/babelizer/render.py +++ b/babelizer/render.py @@ -159,7 +159,7 @@ def prettify_python(path_to_repo): files_to_fix = [ path_to_repo / "setup.py", - path_to_repo / module_name / "bmi.py", + path_to_repo / module_name / "_bmi.py", path_to_repo / module_name / "__init__.py", path_to_repo / "docs" / "conf.py", ] From 6b63054d2cb55d992e0ee0332a228d2fcb2132c8 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:51:46 -0700 Subject: [PATCH 07/34] add a pre-commit config file --- .../.pre-commit-config.yaml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/.pre-commit-config.yaml diff --git a/babelizer/data/{{cookiecutter.package_name}}/.pre-commit-config.yaml b/babelizer/data/{{cookiecutter.package_name}}/.pre-commit-config.yaml new file mode 100644 index 00000000..18420030 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/.pre-commit-config.yaml @@ -0,0 +1,73 @@ +repos: +- repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + name: black + description: "Black: The uncompromising Python code formatter" + entry: black + language: python + language_version: python3 + minimum_pre_commit_version: 2.9.2 + require_serial: true + types_or: [python, pyi] + - id: black-jupyter + name: black-jupyter + description: + "Black: The uncompromising Python code formatter (with Jupyter Notebook support)" + entry: black + language: python + minimum_pre_commit_version: 2.9.2 + require_serial: true + types_or: [python, pyi, jupyter] + additional_dependencies: [".[jupyter]"] + +- repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-bugbear + - flake8-comprehensions + - flake8-simplify + +- repo: https://github.com/asottile/pyupgrade + rev: v2.34.0 + hooks: + - id: pyupgrade + args: [--py39-plus] + +- repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + files: \.py$ + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-builtin-literals + - id: check-added-large-files + - id: check-case-conflict + - id: check-toml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: trailing-whitespace + +- repo: https://github.com/PyCQA/pydocstyle + rev: 6.1.1 + hooks: + - id: pydocstyle + files: babelizer/.*\.py$ + args: + - --convention=numpy + - --add-select=D417 + additional_dependencies: [".[toml]"] + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.982 + hooks: + - id: mypy + additional_dependencies: [types-all] From 0a2edc765b5069ff7084025516ad611e40b08e14 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:52:11 -0700 Subject: [PATCH 08/34] add _version module to hold the current version --- .../{{cookiecutter.package_name}}/_version.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_version.py diff --git a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_version.py b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_version.py new file mode 100644 index 00000000..f697ff61 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/_version.py @@ -0,0 +1 @@ +__version__ = "{{cookiecutter.package_version}}" From 64ffdcde7c0bae78abb81de858fea3e869b84076 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:52:46 -0700 Subject: [PATCH 09/34] add a nox config file --- .../{{cookiecutter.package_name}}/noxfile.py | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/noxfile.py diff --git a/babelizer/data/{{cookiecutter.package_name}}/noxfile.py b/babelizer/data/{{cookiecutter.package_name}}/noxfile.py new file mode 100644 index 00000000..179916ad --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/noxfile.py @@ -0,0 +1,182 @@ +import os +import pathlib +import shutil +from itertools import chain + +import nox + +PROJECT = "{{ cookiecutter.package_name }}" +ROOT = pathlib.Path(__file__).parent +PYTHON_VERSIONS = ["3.9", "3.10", "3.11"] + + +@nox.session(python=PYTHON_VERSIONS, venv_backend="mamba") +def test(session: nox.Session) -> None: + """Run the tests.""" + session.conda_install("--file", "requirements-build.txt") + session.conda_install("--file", "requirements-library.txt") + session.conda_install("--file", "requirements-testing.txt") + + session.install(".[testing]") + +{%- for babelized_class, _ in cookiecutter.components|dictsort %} + session.run("bmi-test", "{{ cookiecutter.package_name }}.bmi:{{ babelized_class }}", "-vvv") +{%- endfor %} + + +@nox.session +def lint(session: nox.Session) -> None: + """Look for lint.""" + session.install("pre-commit") + session.run("pre-commit", "run", "--all-files", "--verbose") + + +@nox.session +def towncrier(session: nox.Session) -> None: + """Check that there is a news fragment.""" + session.install("towncrier") + session.run("towncrier", "check", "--compare-with", "origin/develop") + + +@nox.session(name="build-requirements", reuse_venv=True) +def build_requirements(session: nox.Session) -> None: + """Create requirements files from pyproject.toml.""" + session.install("tomli") + + with open("requirements.txt", "w") as fp: + session.run("python", "requirements.py", stdout=fp) + + for extra in ["dev", "docs", "testing"]: + with open(f"requirements-{extra}.txt", "w") as fp: + session.run("python", "requirements.py", extra, stdout=fp) + + +@nox.session(name="build-docs", reuse_venv=True, venv_backend="mamba") +def build_docs(session: nox.Session) -> None: + """Build the docs.""" + with session.chdir(ROOT): + session.conda_install("--file", "requirements-library.txt") + session.install(".[docs]") + + clean_docs(session) + + with session.chdir(ROOT): + session.run( + "sphinx-apidoc", + "-e", + "-force", + "--no-toc", + "--module-first", + "-o", + "docs/api", + "{{ cookiecutter.package_name }}", + ) + session.run( + "sphinx-build", + "-b", + "html", + # "-W", + "docs", + "build/html", + ) + + +@nox.session(name="live-docs", reuse_venv=True) +def live_docs(session: nox.Session) -> None: + """Build the docs with sphinx-autobuild""" + session.install("sphinx-autobuild") + session.install(".[docs]") + session.run( + "sphinx-apidoc", + "-e", + "-force", + "--no-toc", + "--module-first", + "--templatedir", + "docs/_templates", + "-o", + "docs/api", + "{{ cookiecutter.package_name }}", + ) + session.run( + "sphinx-autobuild", + "-b", + "dirhtml", + "docs", + "build/html", + "--open-browser", + ) + + +@nox.session +def build(session: nox.Session) -> None: + """Build sdist and wheel dists.""" + session.install("pip") + session.install("wheel") + session.install("setuptools") + session.run("python", "--version") + session.run("pip", "--version") + session.run( + "python", "setup.py", "bdist_wheel", "sdist", "--dist-dir", "./wheelhouse" + ) + + +@nox.session +def release(session): + """Tag, build and publish a new release to PyPI.""" + session.install("zest.releaser[recommended]") + session.install("zestreleaser.towncrier") + session.run("fullrelease") + + +@nox.session +def publish_testpypi(session): + """Publish wheelhouse/* to TestPyPI.""" + session.run("twine", "check", "wheelhouse/*") + session.run( + "twine", + "upload", + "--skip-existing", + "--repository-url", + "https://test.pypi.org/legacy/", + "wheelhouse/*.tar.gz", + ) + + +@nox.session +def publish_pypi(session): + """Publish wheelhouse/* to PyPI.""" + session.run("twine", "check", "wheelhouse/*") + session.run( + "twine", + "upload", + "--skip-existing", + "wheelhouse/*.tar.gz", + ) + + +@nox.session(python=False) +def clean(session): + """Remove all .venv's, build files and caches in the directory.""" + shutil.rmtree("build", ignore_errors=True) + shutil.rmtree("wheelhouse", ignore_errors=True) + shutil.rmtree(f"{PROJECT}.egg-info", ignore_errors=True) + shutil.rmtree(".pytest_cache", ignore_errors=True) + shutil.rmtree(".venv", ignore_errors=True) + for p in chain(ROOT.rglob("*.py[co]"), ROOT.rglob("__pycache__")): + if p.is_dir(): + p.rmdir() + else: + p.unlink() + + +@nox.session(python=False, name="clean-docs") +def clean_docs(session: nox.Session) -> None: + """Clean up the docs folder.""" + with session.chdir(ROOT / "build"): + if os.path.exists("html"): + shutil.rmtree("html") + + with session.chdir(ROOT / "docs"): + for p in pathlib.Path("api").rglob("{{ cookiecutter.package_name }}*.rst"): + p.unlink() From afd7d62e6f27751885877313a46de53b00877d18 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 16:56:01 -0700 Subject: [PATCH 10/34] add an api folder to the docs --- .../{{cookiecutter.package_name}}/docs/api/.gitignore | 2 ++ .../data/{{cookiecutter.package_name}}/docs/api/index.rst | 7 +++++++ .../data/{{cookiecutter.package_name}}/docs/index.rst | 8 +------- 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore b/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore new file mode 100644 index 00000000..c221bf4b --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore @@ -0,0 +1,2 @@ +# auto-generated with sphinx-apidoc +{{ cookiecutter.package_name }}*.rst \ No newline at end of file diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst new file mode 100644 index 00000000..e95106be --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst @@ -0,0 +1,7 @@ +Developer Documentation +----------------------- + +.. toctree:: + :maxdepth: 2 + + {{ cookiecutter.package_name }} \ No newline at end of file diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst index 637914bd..ee39a343 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst @@ -6,12 +6,6 @@ Welcome to {{ cookiecutter.package_name }}'s documentation! readme installation - modules + api/index .. usage .. contributing - -Indices and tables -================== -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` From 3adeeeda97ee80a7df0b3617f389897e04a32310 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 17:02:00 -0700 Subject: [PATCH 11/34] move setup utilities into a separate file --- .../setup_utils.py | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/setup_utils.py diff --git a/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py b/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py new file mode 100644 index 00000000..66f9845b --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py @@ -0,0 +1,123 @@ +import contextlib +import os +import subprocess +import sys + +import numpy as np +from numpy.distutils.fcompiler import new_fcompiler +from setuptools import Extension +from setuptools.command.build_ext import build_ext as _build_ext + + +def get_compiler_flags(): + flags = { + "include_dirs": [ + np.get_include(), + os.path.join(sys.prefix, "include"), + {%- for dir in cookiecutter.build.include_dirs %} + "{{ dir|trim }}", + {% endfor %} + ], + "library_dirs": [ + {%- for libdir in cookiecutter.build.library_dirs %} + "{{ libdir|trim }}", + {% endfor %} + ], + "define_macros": [ + {%- if cookiecutter.build.define_macros -%} + {%- for item in cookiecutter.build.define_macros %} + {%- set key_value = item.split('=') %} + ("{{ key_value[0]|trim }}", "{{ key_value[1]|trim }}"),{% endfor %} + {%- endif %} + ], + "undef_macros": [ + {%- if cookiecutter.build.undef_macros -%} + {%- for macro in cookiecutter.build.undef_macros %} + "{{ macro|trim }}",{% endfor %} + {%- endif %} + ], + "extra_compile_args": [ + {%- if cookiecutter.build.extra_compile_args -%} + {%- for arg in cookiecutter.build.extra_compile_args %} + "{{ arg|trim }}",{% endfor %} + {%- endif %} + ], + {%- if cookiecutter.language == 'fortran' %} + "language": "c", + {% else %} + "language": "{{ cookiecutter.language }}", + {% endif -%} + } + + # Locate directories under Windows %LIBRARY_PREFIX%. + if sys.platform.startswith("win"): + flags["include_dirs"].append(os.path.join(sys.prefix, "Library", "include")) + flags["library_dirs"].append(os.path.join(sys.prefix, "Library", "lib")) + + return flags + + +def get_extension_modules(): + flags = get_compiler_flags() + + libraries = [ + {%- if cookiecutter.build.libraries -%} + {%- for lib in cookiecutter.build.libraries %} + "{{ lib|trim }}",{% endfor %} + {%- endif %} + ] + + ext_modules = [ + {%- for babelized_class, component in cookiecutter.components|dictsort %} + Extension( + "{{cookiecutter.package_name}}.lib.{{ babelized_class|lower }}", + ["{{cookiecutter.package_name}}/lib/{{ babelized_class|lower }}.pyx"], + libraries=libraries + ["{{ component.library }}"], + {% if cookiecutter.language == 'fortran' -%} + extra_objects=["{{cookiecutter.package_name}}/lib/bmi_interoperability.o"], + {% endif -%} + **flags, + ), + {%- endfor %} + ] + + return ext_modules + + +@contextlib.contextmanager +def as_cwd(path): + prev_cwd = os.getcwd() + os.chdir(path) + yield + os.chdir(prev_cwd) + + +def build_interoperability(): + compiler = new_fcompiler() + compiler.customize() + + flags = get_compiler_flags() + + cmd = [] + cmd.append(compiler.compiler_f90[0]) + cmd.append(compiler.compile_switch) + if sys.platform.startswith("win") is False: + cmd.append("-fPIC") + for include_dir in flags["include_dirs"]: + if os.path.isabs(include_dir) is False: + include_dir = os.path.join(sys.prefix, "include", include_dir) + cmd.append(f"-I{include_dir}") + cmd.append("bmi_interoperability.f90") + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + raise + + +class build_ext(_build_ext): + + def run(self): + with as_cwd("{{cookiecutter.package_name}}/lib"): + build_interoperability() + _build_ext.run(self) \ No newline at end of file From 0483b0e020b2aa4585285fad9b4876dafb1d69b9 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 28 Nov 2022 18:29:50 -0700 Subject: [PATCH 12/34] remove old travis config file --- babelizer/data/.travis.yml | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 babelizer/data/.travis.yml diff --git a/babelizer/data/.travis.yml b/babelizer/data/.travis.yml deleted file mode 100644 index a239ba3a..00000000 --- a/babelizer/data/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: generic -os: -- linux -- osx -env: - matrix: - - TRAVIS_PYTHON_VERSION="2.7" - - TRAVIS_PYTHON_VERSION="3.4" - - TRAVIS_PYTHON_VERSION="3.5" - - TRAVIS_PYTHON_VERSION="3.6" -sudo: false -before_install: -- | - if [[ $TRAVIS_OS_NAME == "osx" ]]; then - brew remove --force $(brew list) - brew cleanup -s - rm -rf $(brew --cache) - fi -install: -- curl https://raw.githubusercontent.com/csdms/ci-tools/master/install_miniconda.sh | bash -s - $(pwd)/.conda -- export PATH="$(pwd)/.conda/bin:$PATH" -- hash -r -- conda create -n _testing python=$TRAVIS_PYTHON_VERSION && source activate _testing -- conda install --file=requirements_dev.txt -c conda-forge -script: -- pytest From 9e0704d6f7d22a30271aafa6caf7ed479a2c993f Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 29 Nov 2022 15:46:19 -0700 Subject: [PATCH 13/34] create a csdms-styled logo for the babelized component --- babelizer/data/hooks/post_gen_project.py | 7 +++++++ .../.github/workflows/black.yml | 21 ------------------- .../workflows/{flake8.yml => lint.yml} | 0 pyproject.toml | 1 + 4 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 babelizer/data/{{cookiecutter.package_name}}/.github/workflows/black.yml rename babelizer/data/{{cookiecutter.package_name}}/.github/workflows/{flake8.yml => lint.yml} (100%) diff --git a/babelizer/data/hooks/post_gen_project.py b/babelizer/data/hooks/post_gen_project.py index 29961d8b..e6218f5a 100644 --- a/babelizer/data/hooks/post_gen_project.py +++ b/babelizer/data/hooks/post_gen_project.py @@ -4,6 +4,9 @@ from collections import defaultdict from pathlib import Path +from logoizer import logoize + + PROJECT_DIRECTORY = Path.cwd().resolve() LIB_DIRECTORY = Path("{{ cookiecutter.package_name }}", "lib") @@ -84,6 +87,10 @@ def write_api_yaml(folderpath, **kwds): if __name__ == "__main__": keep = set() + make_folder(PROJECT_DIRECTORY / "docs" / "_static") + logoize("{{ cookiecutter.package_name }}", PROJECT_DIRECTORY / "docs" / "_static" / "logo-light.svg", light=True) + logoize("{{ cookiecutter.package_name }}", PROJECT_DIRECTORY / "docs" / "_static" / "logo-dark.svg", light=False) + {%- if cookiecutter.language == 'c' %} keep |= set(["__init__.py", "bmi.c", "bmi.h"]) diff --git a/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/black.yml b/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/black.yml deleted file mode 100644 index 0a161f58..00000000 --- a/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/black.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Black - -on: [push, pull_request] - -jobs: - - format: - # We want to run on external PRs, but not on our own internal PRs as they'll be run - # by the push to the branch. Without this if check, checks are duplicated since - # internal PRs match both the push and pull_request events. - if: - github.event_name == 'push' || github.event.pull_request.head.repo.full_name != - github.repository - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: psf/black@stable - with: - args: ". --check" diff --git a/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/flake8.yml b/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/lint.yml similarity index 100% rename from babelizer/data/{{cookiecutter.package_name}}/.github/workflows/flake8.yml rename to babelizer/data/{{cookiecutter.package_name}}/.github/workflows/lint.yml diff --git a/pyproject.toml b/pyproject.toml index 9a988b3f..a08dda59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ dependencies = [ "tomlkit", "isort>=5", "cookiecutter", + "logoizer @ git+https://github.com/mcflugen/logoizer", ] dynamic = ["readme", "version"] From 16cbcad726553d9684585c132f3269989c4100a0 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 29 Nov 2022 15:48:53 -0700 Subject: [PATCH 14/34] switch to furo theme for docs --- .../docs/conf.py | 81 ++++++++++++++++--- .../docs/index.rst | 32 ++++++-- 2 files changed, 99 insertions(+), 14 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py index daa0f150..7b423be6 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py @@ -15,8 +15,13 @@ # relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. # +import os +import pathlib + import {{ cookiecutter.package_name }} +docs_dir = os.path.dirname(__file__) + # -- General configuration --------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. @@ -25,19 +30,32 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "sphinx.ext.napoleon", + "sphinx.ext.autosummary", + "sphinx_inline_tabs", + "sphinx_copybutton", + "sphinxcontrib.towncrier", +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. project = '{{ cookiecutter.package_name }}' @@ -63,10 +81,10 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -77,21 +95,66 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "furo" +html_title = "{{ cookiecutter.package_name }}" + # Theme options are theme-specific and customize the look and feel of a # theme further. For a list of options available for each theme, see the # documentation. # -# html_theme_options = {} +html_theme_options = { + "announcement": None, + "source_repository": "https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }}/", + "source_branch": "main", + "source_directory": "docs", + "sidebar_hide_name": False, + "footer_icons": [ + { + "name": "power", + "url": "https://csdms.colorado.edu", + "html": """ + + Powered by CSDMS + """, + "class": "", + }, + ], +} + # 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'] +html_static_path = ["_static"] # -- Options for HTMLHelp output --------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = "{{ cookiecutter.package_name }}doc" + +# -- Options for intersphinx extension --------------------------------------- + +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), +} + +# -- Options for todo extension ---------------------------------------------- + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + +# -- Options for napoleon extension ---------------------------------------------- + +napoleon_numpy_docstring = True +napoleon_google_docstring = False +napoleon_include_init_with_doc = True +napoleon_include_special_with_doc = True + + +# -- Options for towncrier_draft extension -------------------------------------------- + +towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-release', 'sphinx-version' +towncrier_draft_include_empty = True +towncrier_draft_working_directory = pathlib.Path(docs_dir).parent diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst index ee39a343..c0616c17 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst @@ -1,11 +1,33 @@ -Welcome to {{ cookiecutter.package_name }}'s documentation! -==========={{ '=' * cookiecutter.package_name | length }}================= +.. image:: _static/logo-light.svg + :align: center + :scale: 15% + :alt: {{ cookiecutter.package_name }} + :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ + :class: only-light + +.. image:: _static/logo-dark.svg + :align: center + :scale: 15% + :alt: {{ cookiecutter.package_name }} + :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ + :class: only-dark + .. toctree:: :maxdepth: 2 - :caption: Contents: + :caption: User Guide + :hidden: true readme installation - api/index -.. usage + usage .. contributing + +.. toctree:: + :maxdepth: 2 + :caption: Contribute + :hidden: true + + api/index + authors + changelog + license From 98945c12dd0a052a85887634eff23f76bb3dd6f3 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 29 Nov 2022 15:50:25 -0700 Subject: [PATCH 15/34] remove unicode from license --- LICENSE.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.rst b/LICENSE.rst index 8c80f6df..6186a570 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © `2020` `Community Surface Dynamics Modeling System` +Copyright (c) `2020` `Community Surface Dynamics Modeling System` Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 47b3ccf8d11ddc07ff226503604f82d640ec2aef Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 29 Nov 2022 15:50:52 -0700 Subject: [PATCH 16/34] add towncrier section to pyproject.toml --- .../data/{{cookiecutter.package_name}}/pyproject.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml index 6b06c5c6..3d099c94 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml +++ b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml @@ -95,3 +95,13 @@ ignore = [ "{{ cookiecutter.package_name }}/data", "{{ cookiecutter.package_name }}/data/**/*", ] + +[tool.towncrier] +directory = "news" +package = "{{ cookiecutter.package_name }}" +filename = "CHANGES.rst" +single_file = true +underlines = "-^\"" +issue_format = "`#{issue} `_" +title_format = "{version} ({project_date})" +wrap = true From 0c640605615e4d9721d0e29944173492b050dea0 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 29 Nov 2022 15:51:06 -0700 Subject: [PATCH 17/34] remove minor lint --- .../{{cookiecutter.package_name}}/docs/api/.gitignore | 2 +- .../{{cookiecutter.package_name}}/docs/api/index.rst | 2 +- .../data/{{cookiecutter.package_name}}/setup_utils.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore b/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore index c221bf4b..49355355 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/api/.gitignore @@ -1,2 +1,2 @@ # auto-generated with sphinx-apidoc -{{ cookiecutter.package_name }}*.rst \ No newline at end of file +{{ cookiecutter.package_name }}*.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst index e95106be..a4dbff20 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst @@ -4,4 +4,4 @@ Developer Documentation .. toctree:: :maxdepth: 2 - {{ cookiecutter.package_name }} \ No newline at end of file + {{ cookiecutter.package_name }} diff --git a/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py b/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py index 66f9845b..b2bbca13 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py +++ b/babelizer/data/{{cookiecutter.package_name}}/setup_utils.py @@ -48,7 +48,7 @@ def get_compiler_flags(): "language": "{{ cookiecutter.language }}", {% endif -%} } - + # Locate directories under Windows %LIBRARY_PREFIX%. if sys.platform.startswith("win"): flags["include_dirs"].append(os.path.join(sys.prefix, "Library", "include")) @@ -66,7 +66,7 @@ def get_extension_modules(): "{{ lib|trim }}",{% endfor %} {%- endif %} ] - + ext_modules = [ {%- for babelized_class, component in cookiecutter.components|dictsort %} Extension( @@ -80,7 +80,7 @@ def get_extension_modules(): ), {%- endfor %} ] - + return ext_modules @@ -95,7 +95,7 @@ def as_cwd(path): def build_interoperability(): compiler = new_fcompiler() compiler.customize() - + flags = get_compiler_flags() cmd = [] @@ -120,4 +120,4 @@ class build_ext(_build_ext): def run(self): with as_cwd("{{cookiecutter.package_name}}/lib"): build_interoperability() - _build_ext.run(self) \ No newline at end of file + _build_ext.run(self) From 6c28bfbc943c9548a926a2a1c62083798aa30c41 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 10:59:58 -0700 Subject: [PATCH 18/34] add an update session to the template nox file --- babelizer/data/{{cookiecutter.package_name}}/noxfile.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/babelizer/data/{{cookiecutter.package_name}}/noxfile.py b/babelizer/data/{{cookiecutter.package_name}}/noxfile.py index 179916ad..c90c443b 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/noxfile.py +++ b/babelizer/data/{{cookiecutter.package_name}}/noxfile.py @@ -24,6 +24,13 @@ def test(session: nox.Session) -> None: {%- endfor %} +@nox.session(venv_backend="mamba") +def update(session: nox.Session) -> None: + session.conda_install("babelizer") + + session.run("babelize", "update") + + @nox.session def lint(session: nox.Session) -> None: """Look for lint.""" From f06e9a283046dd0e4850131f6177df9511a54c30 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 11:50:37 -0700 Subject: [PATCH 19/34] format license as rst, add .rst extension --- .../{{cookiecutter.package_name}}/CHANGES.rst | 9 +++++---- .../{LICENSE => LICENSE.rst} | 17 +++++++++++------ .../pyproject.toml | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) rename babelizer/data/{{cookiecutter.package_name}}/{LICENSE => LICENSE.rst} (92%) diff --git a/babelizer/data/{{cookiecutter.package_name}}/CHANGES.rst b/babelizer/data/{{cookiecutter.package_name}}/CHANGES.rst index 8e176aa1..e6e128b6 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/CHANGES.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/CHANGES.rst @@ -1,8 +1,9 @@ -Changelog for {{cookiecutter.package_name}} -=============={{ '=' * cookiecutter.package_name | length }} +Release Notes +============= -0.2.0 (unreleased) -------------------- +.. towncrier-draft-entries:: Not yet released + +.. towncrier release notes start 0.1.0 ({% now 'local', '%Y-%m-%d' %}) diff --git a/babelizer/data/{{cookiecutter.package_name}}/LICENSE b/babelizer/data/{{cookiecutter.package_name}}/LICENSE.rst similarity index 92% rename from babelizer/data/{{cookiecutter.package_name}}/LICENSE rename to babelizer/data/{{cookiecutter.package_name}}/LICENSE.rst index 9a062bc5..e1d6f40e 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/LICENSE +++ b/babelizer/data/{{cookiecutter.package_name}}/LICENSE.rst @@ -1,7 +1,8 @@ {% if cookiecutter.open_source_license == 'MIT License' -%} MIT License +=========== -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.info.full_name }} +Copyright (c) *{% now 'local', '%Y' %}*, *{{ cookiecutter.info.full_name }}* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,10 +22,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. {% elif cookiecutter.open_source_license == 'BSD License' %} - BSD License +=========== -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.info.full_name }} +Copyright (c) *{% now 'local', '%Y' %}*, *{{ cookiecutter.info.full_name }}* All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -53,16 +54,18 @@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISE OF THE POSSIBILITY OF SUCH DAMAGE. {% elif cookiecutter.open_source_license == 'ISC License' -%} ISC License +=========== -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.info.full_name }} +Copyright (c) *{% now 'local', '%Y' %}*, *{{ cookiecutter.info.full_name }}* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. {% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} Apache Software License 2.0 +=========================== -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.info.full_name }} +Copyright (c) *{% now 'local', '%Y' %}*, *{{ cookiecutter.info.full_name }}* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -77,10 +80,12 @@ See the License for the specific language governing permissions and limitations under the License. {% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} GNU GENERAL PUBLIC LICENSE +========================== + Version 3, 29 June 2007 {{ cookiecutter.info.project_short_description }} - Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.info.full_name }} + Copyright (c) *{% now 'local', '%Y' %}*, *{{ cookiecutter.info.full_name }}* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml index 3d099c94..6ed8bb79 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml +++ b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml @@ -53,7 +53,7 @@ testing = [ ] [tool.setuptools.dynamic] -readme = {file = ["README.rst", "CREDITS.rst", "CHANGES.rst", "LICENSE"]} +readme = {file = ["README.rst", "CREDITS.rst", "CHANGES.rst", "LICENSE.rst"]} version = {attr = "{{ cookiecutter.package_name }}._version.__version__"} [tool.setuptools] From 6675189e694dc1f2c168912d34411e53efb062e0 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 11:53:56 -0700 Subject: [PATCH 20/34] fix adding extra lines when rendering babel.toml --- babelizer/metadata.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/babelizer/metadata.py b/babelizer/metadata.py index 1de02e78..1b9e68f8 100644 --- a/babelizer/metadata.py +++ b/babelizer/metadata.py @@ -148,11 +148,11 @@ def __init__( package = plugin config = { - "library": library or {}, - "build": build or {}, - "package": package or {}, - "info": info or {}, - "ci": ci or {}, + "library": dict(library or {}), + "build": dict(build or {}), + "package": dict(package or {}), + "info": dict(info or {}), + "ci": dict(ci or {}), } BabelMetadata.validate(config) @@ -354,7 +354,7 @@ def norm(config): if "entry_point" in config["library"]: libraries = BabelMetadata._handle_old_style_entry_points(config["library"]) else: - libraries = config["library"] + libraries = {k: dict(v) for k, v in config["library"].items()} if "plugin_author" in config["info"]: info = BabelMetadata._handle_old_style_info(config["info"]) From 89d0be1de23bb8a50973e11ec682ada35b2458ff Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 11:55:23 -0700 Subject: [PATCH 21/34] fix setup_utils.py after rendering project --- babelizer/render.py | 1 + 1 file changed, 1 insertion(+) diff --git a/babelizer/render.py b/babelizer/render.py index afaa2e4a..c10829df 100644 --- a/babelizer/render.py +++ b/babelizer/render.py @@ -159,6 +159,7 @@ def prettify_python(path_to_repo): files_to_fix = [ path_to_repo / "setup.py", + path_to_repo / "setup_utils.py", path_to_repo / module_name / "_bmi.py", path_to_repo / module_name / "__init__.py", path_to_repo / "docs" / "conf.py", From 2ddef0727463090348315b5a000c5695c406c701 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 11:57:51 -0700 Subject: [PATCH 22/34] add stub files for package metadata --- .../data/{{cookiecutter.package_name}}/docs/authors.rst | 1 + .../data/{{cookiecutter.package_name}}/docs/babel.rst | 7 +++++++ .../data/{{cookiecutter.package_name}}/docs/changelog.rst | 1 + .../data/{{cookiecutter.package_name}}/docs/license.rst | 1 + 4 files changed, 10 insertions(+) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/changelog.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/license.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst new file mode 100644 index 00000000..e122f914 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst new file mode 100644 index 00000000..1f35f391 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst @@ -0,0 +1,7 @@ +Configuration +============= + +The following *babelizer* configuration file was used to generate this project. + +.. literalinclude:: ../babel.toml + :language: toml \ No newline at end of file diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/changelog.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/changelog.rst new file mode 100644 index 00000000..d9e113ec --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/changelog.rst @@ -0,0 +1 @@ +.. include:: ../CHANGES.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst new file mode 100644 index 00000000..7ba161e5 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst @@ -0,0 +1 @@ +.. include:: ../LICENSE From 8d6b6d33b5feb760bca160b29651ce9a3507d284 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 12:08:16 -0700 Subject: [PATCH 23/34] add install instructions and quick intro environments --- .../docs/developer_install.rst | 58 +++++++++++++++++++ .../docs/environments.rst | 43 ++++++++++++++ .../docs/quickstart.rst | 18 ++++++ 3 files changed, 119 insertions(+) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/developer_install.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/environments.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/quickstart.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/developer_install.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/developer_install.rst new file mode 100644 index 00000000..a6dcc70a --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/developer_install.rst @@ -0,0 +1,58 @@ +.. _developer_install: + +================= +Developer Install +================= + +.. important:: + + The following commands will install *{{ cookiecutter.package_name }}* into your current environment. Although + not necessary, we **highly recommend** you install *{{ cookiecutter.package_name }}* into its own + :ref:`virtual environment `. + +If you will be modifying code or contributing new code to *{{ cookiecutter.package_name }}*, you will first +need to get *{{ cookiecutter.package_name }}*'s source code and then install *{{ cookiecutter.package_name }}* from that code. + +Source Install +-------------- + +*{{ cookiecutter.package_name }}* is actively being developed on GitHub, where the code is freely available. +If you would like to modify or contribute code, you can either clone our +repository + +.. code-block:: bash + + git clone git://github.com/pymt-lab/{{ cookiecutter.package_name }}.git + +or download the `tarball `_ +(a zip file is available for Windows users): + +.. code-block:: bash + + curl -OL https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }}/tarball/master + +Once you have a copy of the source code, you can install it into your current +Python environment, + +.. tab:: mamba + + .. code-block:: bash + + cd {{ cookiecutter.package_name }} + mamba install --file=requirements.txt + pip install -e . + +.. tab:: conda + + .. code-block:: bash + + cd {{ cookiecutter.package_name }} + conda install --file=requirements.txt + pip install -e . + +.. tab:: pip + + .. code-block:: bash + + cd {{ cookiecutter.package_name }} + pip install -e . diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/environments.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/environments.rst new file mode 100644 index 00000000..7b1f4c09 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/environments.rst @@ -0,0 +1,43 @@ +.. _virtual_environments: + +==================== +Virtual Environments +==================== + +A virtual environment is a self-contained directory tree that contains a Python installation for a particular +version of Python along with additional packages. It solves the problem of one application's +package requirements conflicting with another's. + +Two popular tools used for creating virtual environments are the built-in *venv* module and *conda* +(or the *much* faster and more reliable *mamba*). For virtual environments created using *conda*/*mamba*, +you can use either *conda*/*mamba* or *pip* to install additional packages, while *venv*-created environments +should stick with *pip*. + +.. tab:: mamba + + .. code-block:: bash + + conda install mamba -c conda-forge + mamba create -n {{ cookiecutter.package_name }} + mamba activate {{ cookiecutter.package_name }} + +.. tab:: conda + + .. code-block:: bash + + conda create -n {{ cookiecutter.package_name }} + conda activate {{ cookiecutter.package_name }} + +.. tab:: venv + + .. code-block:: bash + + python -m venv .venv + source .venv/bin/activate + +Note that you will need to activate this environment every time you want to use it in a new shell. + +Helpful links on managing virtual environments: + +* `conda environments `_. +* `venv environments `_. diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/quickstart.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/quickstart.rst new file mode 100644 index 00000000..8753666e --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/quickstart.rst @@ -0,0 +1,18 @@ +Quickstart +========== + +.. note:: + + The following commands will install *{{ cookiecutter.package_name}}* into your current + environment. Although not necessary, we **highly recommend** you install + *{{ cookiecutter.package_name}}* into its own + :ref:`virtual environment `. + +.. include:: ../README.rst + :start-after: .. start-quickstart + :end-before: .. end-quickstart + +If you would like the very latest development version of *{{ cookiecutter.package_name}}* +or want to modify or contribute code to the *{{ cookiecutter.package_name}}* project, +you will need to do a :ref:`developer installation ` of +*{{ cookiecutter.package_name }}* from source. From ef3c4a4a91837073a499e90f8641c612fa3fb4f1 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 12:09:20 -0700 Subject: [PATCH 24/34] add quickstart, usage, and updating sections to readme --- .../{{cookiecutter.package_name}}/README.rst | 162 ++++++++++++------ .../docs/updating.rst | 6 + .../docs/usage.rst | 6 + 3 files changed, 125 insertions(+), 49 deletions(-) create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/README.rst b/babelizer/data/{{cookiecutter.package_name}}/README.rst index cf2252d9..7fc45494 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/README.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/README.rst @@ -27,80 +27,144 @@ {%- endif %} -{{ cookiecutter.info.project_short_description }} +.. start-intro + +**{{ cookiecutter.info.project_short_description }}** + +This project provides a wrapped version (using the `babelizer `_ tool) +of the {{ cookiecutter.language }} library +components that expose a Basic Model Interface. This allows these components to be imported and used within +Python and the Python Modeling Toolkit, PyMT. + + +.. list-table:: + :header-rows: 1 + :width: 80% + :widths: auto + + * - Component + - PyMT + {% for babelized_class, component in cookiecutter.components|dictsort -%} + * - :class:`~{{ cookiecutter.package_name}}.{{ babelized_class }}` + - + .. code-block:: pycon + + >>> from pymt.models import {{ babelized_class }} + {% endfor %} + +.. end-intro + {% if is_open_source %} * Free software: {{ cookiecutter.open_source_license }} * Documentation: https://{{ cookiecutter.package_name | replace("_", "-") }}.readthedocs.io. {% endif %} -{% set mwidth = ["Component" | length] -%} -{%- for babelized_class, component in cookiecutter.components|dictsort %} - {%- if babelized_class|length > mwidth[0] -%} - {% set _ = mwidth.pop() -%} - {% set _ = mwidth.append(babelized_class|length) -%} - {%- endif -%} -{%- endfor %} -{% set max_width = mwidth[0] %} - -{%- set width_col_1 = max_width -%} -{%- set width_col_2 = max_width + "`from pymt.models import `" | length -%} -{% set fmt = "%-" + max_width|string + "s" %} -{{ '=' * max_width }} {{ '=' * width_col_2 }} -{{ fmt | format("Component",) }} PyMT -{{ '=' * max_width }} {{ '=' * width_col_2 }} + +Quickstart +========== + +.. start-quickstart + +To get started you will need to install the *{{ cookiecutter.package_name }}* package, which is currently distributed +on *conda-forge*. The easiest way to install *{{ cookiecutter.package_name }}* into your current environment using either *mamba* or *conda*. + +.. tab:: mamba + + .. code:: bash + + mamba install {{ cookiecutter.package_name }} + +.. tab:: conda + + .. code:: bash + + conda install {{ cookiecutter.package_name }} + +.. end-quickstart + +Usage +===== + +.. start-usage + +There are two ways to use the data components provided by this package: directly through it's Basic +Model Interface, or as a PyMT plugin. + +A BMI is provided by each component in this package: +{%- for babelized_class, component in cookiecutter.components|dictsort -%} +:class:`~{{ cookiecutter.package_name}}.{{ babelized_class }}` +{% endfor %}. + + {% for babelized_class, component in cookiecutter.components|dictsort -%} -{{ fmt | format(babelized_class) }} `from pymt.models import {{ babelized_class }}` -{% endfor -%} -{{ '=' * max_width }} {{ '=' * width_col_2 }} ---------------- -Installing pymt ---------------- +.. code-block:: pycon -Installing `pymt` from the `conda-forge` channel can be achieved by adding -`conda-forge` to your channels with: + >>> from {{ cookiecutter.package_name}} import {{ babelized_class }} + >>> model = {{ babelized_class }}() + >>> model.get_component_name() # Get the name of the component + >>> model.get_output_var_names() # Get a list of the component's output variables -.. code:: +The PyMT provides a more Pythonic and convenient way to use the component, - conda config --add channels conda-forge +.. code-block:: pycon -*Note*: Before installing `pymt`, you may want to create a separate environment -into which to install it. This can be done with, + >>> from pymt.models import {{ babelized_class }} + >>> model = {{ babelized_class }}() + >>> model.component_name + >>> model.output_var_names -.. code:: +{% endfor %} - conda create -n pymt python=3 - conda activate pymt -Once the `conda-forge` channel has been enabled, `pymt` can be installed with: +.. note:: -.. code:: + If you will be using this project's components through the PyMT, you will first need to install + PyMT. This can be done using either *mamba* or *conda*. - conda install pymt + .. tab:: mamba -It is possible to list all of the versions of `pymt` available on your platform with: + .. code-block:: bash -.. code:: + mamba install pymt -c conda-forge - conda search pymt --channel conda-forge + .. tab:: conda ------------{{ '-' * cookiecutter.package_name | length }} -Installing {{ cookiecutter.package_name }} ------------{{ '-' * cookiecutter.package_name | length }} + .. code-block:: bash -{% if cookiecutter.package_requirements -%} -Once `pymt` is installed, the dependencies of `{{ cookiecutter.package_name }}` can -be installed with: + conda install pymt -c conda-forge -.. code:: - conda install {{ cookiecutter.package_requirements.split(',') | join(" ") }} +.. end-usage -{%- endif %} -To install `{{ cookiecutter.package_name }}`, +Updating +======== + +.. start-updating + +This project has been automatically generated using the `babelizer `_ tool. +If you have made changes to the project's ``babel.toml`` file or the would like to rerender the project +with a newer version of the *babelizer*, you can do this either directly with the *babelize* command +or using *nox*. + +.. warning:: + + Many of the files in the project are auto-generated by the *babelizer* and so any changes that you've + made to them will likely be lost after running the following commands. + +.. tab:: nox + + .. code:: bash + + nox -s update + +.. tab:: babelizer + + .. code:: bash + + babelize update -.. code:: - conda install {{ cookiecutter.package_name }} +.. end-updating diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst new file mode 100644 index 00000000..6c108214 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst @@ -0,0 +1,6 @@ +Updating +========== + +.. include:: ../README.rst + :start-after: .. start-updating + :end-before: .. end-updating \ No newline at end of file diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst new file mode 100644 index 00000000..c8b1e279 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst @@ -0,0 +1,6 @@ +Usage +===== + +.. include:: ../README.rst + :start-after: .. start-usage + :end-before: .. end-usage \ No newline at end of file From e53eaf8e6e04e1b7e047ab6bf72369ce4a306d00 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 12:10:27 -0700 Subject: [PATCH 25/34] add new sections to the table of contents --- .../docs/index.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst index c0616c17..b3c2c429 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst @@ -12,22 +12,29 @@ :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ :class: only-dark +.. include:: ../README.rst + :start-after: start-intro + :end-before: end-intro + .. toctree:: :maxdepth: 2 :caption: User Guide - :hidden: true + :hidden: - readme - installation + quickstart usage + API + babel .. contributing .. toctree:: :maxdepth: 2 :caption: Contribute - :hidden: true + :hidden: - api/index + developer_install + environments + updating authors changelog license From 515824a10eed2cbfcc28ba0ac7a06bd837c0603e Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 12:14:06 -0700 Subject: [PATCH 26/34] remove unused doc files --- .../docs/index.rst | 40 ------------- .../docs/installation.rst | 59 ------------------- .../docs/readme.rst | 1 - 3 files changed, 100 deletions(-) delete mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/index.rst delete mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/installation.rst delete mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/readme.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst deleted file mode 100644 index b3c2c429..00000000 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst +++ /dev/null @@ -1,40 +0,0 @@ -.. image:: _static/logo-light.svg - :align: center - :scale: 15% - :alt: {{ cookiecutter.package_name }} - :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ - :class: only-light - -.. image:: _static/logo-dark.svg - :align: center - :scale: 15% - :alt: {{ cookiecutter.package_name }} - :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ - :class: only-dark - -.. include:: ../README.rst - :start-after: start-intro - :end-before: end-intro - -.. toctree:: - :maxdepth: 2 - :caption: User Guide - :hidden: - - quickstart - usage - API - babel -.. contributing - -.. toctree:: - :maxdepth: 2 - :caption: Contribute - :hidden: - - developer_install - environments - updating - authors - changelog - license diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/installation.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/installation.rst deleted file mode 100644 index 66331a4b..00000000 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/installation.rst +++ /dev/null @@ -1,59 +0,0 @@ -.. highlight:: shell - -============ -Installation -============ - - -Stable release --------------- - -Installing {{ cookiecutter.package_name }} from the `conda-forge` channel can be achieved by adding -`conda-forge` to your channels with: - -.. code:: - - conda config --add channels conda-forge - -To install {{ cookiecutter.package_name }}, run this command in your terminal: - -.. code-block:: console - - $ conda install {{ cookiecutter.package_name }} - -This is the preferred method to install {{ cookiecutter.package_name }}, as it will always install the most recent stable release. - -If you don't have `conda`_ installed, this `Anaconda installation guide`_ can guide -you through the process. - -.. _conda: https://docs.anaconda.com/anaconda/ -.. _Anaconda installation guide: https://docs.anaconda.com/anaconda/install/ - - -From sources ------------- - -The sources for {{ cookiecutter.package_name }} can be downloaded from the `Github repo`_. - -You can either clone the public repository: - -.. code-block:: console - - $ git clone git://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }} - -Or download the `tarball`_: - -.. code-block:: console - - $ curl -OL https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }}/tarball/master - -Once you have a copy of the source, you can install it with: - -.. code-block:: console - - $ conda install --file=requirements.txt - $ python setup.py install - - -.. _Github repo: https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }} -.. _tarball: https://github.com/{{ cookiecutter.info.github_username }}/{{ cookiecutter.package_name }}/tarball/master diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/readme.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/readme.rst deleted file mode 100644 index 72a33558..00000000 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/readme.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../README.rst From b1215edf6cce3f90375c900aeed3e6be702a8fbf Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 12:21:45 -0700 Subject: [PATCH 27/34] remove lint --- babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst | 2 +- babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst | 2 +- babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst index 1f35f391..8ce04913 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/babel.rst @@ -4,4 +4,4 @@ Configuration The following *babelizer* configuration file was used to generate this project. .. literalinclude:: ../babel.toml - :language: toml \ No newline at end of file + :language: toml diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst index 6c108214..c545fc4f 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/updating.rst @@ -3,4 +3,4 @@ Updating .. include:: ../README.rst :start-after: .. start-updating - :end-before: .. end-updating \ No newline at end of file + :end-before: .. end-updating diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst index c8b1e279..63ce3824 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/usage.rst @@ -3,4 +3,4 @@ Usage .. include:: ../README.rst :start-after: .. start-usage - :end-before: .. end-usage \ No newline at end of file + :end-before: .. end-usage From de7aab50d34ce8832636a87c149a13edcc91cf82 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 13:33:21 -0700 Subject: [PATCH 28/34] remove unused api/index --- .../docs/api/index.rst | 7 ---- .../docs/index.rst | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) delete mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst create mode 100644 babelizer/data/{{cookiecutter.package_name}}/docs/index.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst deleted file mode 100644 index a4dbff20..00000000 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/api/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -Developer Documentation ------------------------ - -.. toctree:: - :maxdepth: 2 - - {{ cookiecutter.package_name }} diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst new file mode 100644 index 00000000..b3c2c429 --- /dev/null +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/index.rst @@ -0,0 +1,40 @@ +.. image:: _static/logo-light.svg + :align: center + :scale: 15% + :alt: {{ cookiecutter.package_name }} + :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ + :class: only-light + +.. image:: _static/logo-dark.svg + :align: center + :scale: 15% + :alt: {{ cookiecutter.package_name }} + :target: https://{{ cookiecutter.package_name }}.readthedocs.org/ + :class: only-dark + +.. include:: ../README.rst + :start-after: start-intro + :end-before: end-intro + +.. toctree:: + :maxdepth: 2 + :caption: User Guide + :hidden: + + quickstart + usage + API + babel +.. contributing + +.. toctree:: + :maxdepth: 2 + :caption: Contribute + :hidden: + + developer_install + environments + updating + authors + changelog + license From a0559eba1aabb56e681bd86ec83b58615802649f Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 13:42:12 -0700 Subject: [PATCH 29/34] add missing type hint --- babelizer/data/{{cookiecutter.package_name}}/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py index 7b423be6..0395fb7a 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/conf.py @@ -81,7 +81,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = [] +exclude_patterns : list[str] = [] # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" From bfed30c848f915c1d566577853ee879ace4a6ad5 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 13:42:23 -0700 Subject: [PATCH 30/34] fix stub files to point to correct files --- babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst | 2 +- babelizer/data/{{cookiecutter.package_name}}/docs/license.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst index e122f914..19353565 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/authors.rst @@ -1 +1 @@ -.. include:: ../AUTHORS.rst +.. include:: ../CREDITS.rst diff --git a/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst b/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst index 7ba161e5..68c5792f 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/docs/license.rst @@ -1 +1 @@ -.. include:: ../LICENSE +.. include:: ../LICENSE.rst From ca561482cdf378e2a80e4d86eb1f590077067847 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 13:45:14 -0700 Subject: [PATCH 31/34] clean up text on main docs page --- .../data/{{cookiecutter.package_name}}/README.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/README.rst b/babelizer/data/{{cookiecutter.package_name}}/README.rst index 7fc45494..39a573a8 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/README.rst +++ b/babelizer/data/{{cookiecutter.package_name}}/README.rst @@ -29,23 +29,22 @@ .. start-intro -**{{ cookiecutter.info.project_short_description }}** - This project provides a wrapped version (using the `babelizer `_ tool) -of the {{ cookiecutter.language }} library -components that expose a Basic Model Interface. This allows these components to be imported and used within +of components within the following following libraries that expose a Basic Model Interface. +This allows these components to be imported and used within Python and the Python Modeling Toolkit, PyMT. - .. list-table:: :header-rows: 1 - :width: 80% + :width: 90% :widths: auto - * - Component + * - Library + - Component - PyMT {% for babelized_class, component in cookiecutter.components|dictsort -%} - * - :class:`~{{ cookiecutter.package_name}}.{{ babelized_class }}` + * - {{ component.library }} + - :class:`~{{ cookiecutter.package_name }}.{{ babelized_class }}` - .. code-block:: pycon From 154923ae80fc8866b67adba4c8fd8123e738e3ea Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 13:45:37 -0700 Subject: [PATCH 32/34] remove setuptools version requirement --- babelizer/data/{{cookiecutter.package_name}}/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml index 6ed8bb79..481b4e57 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml +++ b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["cython", "numpy", "setuptools<60", "wheel"] +requires = ["cython", "numpy", "setuptools", "wheel"] [project] name = "{{cookiecutter.package_name}}" From afad29efed05e61960c940c947b9b278af7806df Mon Sep 17 00:00:00 2001 From: mcflugen Date: Fri, 2 Dec 2022 14:35:55 -0700 Subject: [PATCH 33/34] add news fragment --- news/84.feature | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 news/84.feature diff --git a/news/84.feature b/news/84.feature new file mode 100644 index 00000000..56c58cba --- /dev/null +++ b/news/84.feature @@ -0,0 +1,3 @@ + +Updated the generated project files to better follow modern best practices +for Python projects. From c3c567498735e51f73a4045f2b33e79aa5e85b4b Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 5 Mar 2024 10:39:20 -0700 Subject: [PATCH 34/34] update python versions for the templates to 3.10+ --- babelizer/data/cookiecutter.json | 2 +- .../.github/workflows/lint.yml | 8 ++++---- .../data/{{cookiecutter.package_name}}/pyproject.toml | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/babelizer/data/cookiecutter.json b/babelizer/data/cookiecutter.json index 3c2432eb..c99a7079 100644 --- a/babelizer/data/cookiecutter.json +++ b/babelizer/data/cookiecutter.json @@ -16,7 +16,7 @@ }, "ci": { "os": ["ubuntu", "macos", "windows"], - "python_version": ["3.7", "3.8", "3.9"] + "python_version": ["3.10", "3.11", "3.12"] }, "package_name": "package", "package_requirements": "", diff --git a/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/lint.yml b/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/lint.yml index 577da960..7f1d7e9c 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/lint.yml +++ b/babelizer/data/{{cookiecutter.package_name}}/.github/workflows/lint.yml @@ -15,12 +15,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.12 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.12 - name: Lint run: | - pip install flake8 - flake8 {{ cookiecutter.package_name }} + pip install nox + nox -s lint diff --git a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml index 481b4e57..b0077dce 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml +++ b/babelizer/data/{{cookiecutter.package_name}}/pyproject.toml @@ -18,9 +18,11 @@ classifiers=[ "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] -requires-python = ">=3.8" +requires-python = ">=3.10" keywords=["bmi", "pymt"] dynamic = ["readme", "version"] dependencies = [