From 11a48bba9a7397b635f435d508a68064305918d2 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 11:48:31 -0700 Subject: [PATCH 01/19] require python 3.10+ --- pyproject.toml | 202 +++++++++++++++++++++++++++---------------------- 1 file changed, 113 insertions(+), 89 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9a988b3f..7c2ceceb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,111 +1,152 @@ -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" - [project] name = "babelizer" +requires-python = ">=3.10" description = "Wrap BMI libraries with Python bindings" +keywords = [ + "bmi", + "component modeling", + "geosciences", + "interoperability", + "model coupling", + "numerical modeling", + "pymt", +] authors = [ - {name = "Eric Hutton", email = "huttone@colorado.edu"}, + { name = "Eric Hutton", email = "huttone@colorado.edu" }, ] maintainers = [ - {name = "Eric Hutton", email = "huttone@colorado.edu"}, - {name = "Mark Piper", email = "mark.piper@colorado.edu"}, + { name = "Eric Hutton", email = "huttone@colorado.edu" }, + { name = "Mark Piper", email = "mark.piper@colorado.edu" }, ] -keywords = [ - "bmi", - "component modeling", - "geosciences", - "interoperability", - "model coupling", - "numerical modeling", - "pymt", -] -license = {text = "MIT License"} classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Software Development :: Code Generators", -] -requires-python = ">=3.8" + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Code Generators", +] dependencies = [ - "black", - "click", - "gitpython", - "pyyaml", - "tomlkit", - "isort>=5", - "cookiecutter", -] -dynamic = ["readme", "version"] + "black", + "click", + "cookiecutter", + "gitpython", + "isort>=5", + "pyyaml", + "tomlkit", +] +dynamic = [ + "readme", + "version", +] + +[project.license] +text = "MIT" [project.urls] -homepage = "https://babelizer.readthedocs.io/" +changelog = "https://github.com/csdms/babelizer/blob/master/CHANGES.rst" documentation = "https://babelizer.readthedocs.io/" +homepage = "https://babelizer.readthedocs.io/" repository = "https://github.com/csdms/babelizer" -changelog = "https://github.com/csdms/babelizer/blob/master/CHANGES.rst" [project.optional-dependencies] dev = [ - "black", - "flake8", - "flake8-bugbear", - "isort", - "nox", - "pre-commit", - "towncrier", + "black", + "flake8", + "flake8-bugbear", + "isort", + "nox", + "pre-commit", + "towncrier", ] docs = [ - "sphinx>=4", - "sphinx-click", - "sphinx-copybutton", - "sphinx-inline-tabs", - "sphinxcontrib.towncrier", - "pygments>=2.4", - "sphinx-inline-tabs", - "furo", + "furo", + "pygments>=2.4", + "sphinx-click", + "sphinx-copybutton", + "sphinx-inline-tabs", + "sphinx-inline-tabs", + "sphinx>=4", + "sphinxcontrib.towncrier", ] testing = [ - "pytest", - "pytest-cov", - "pytest-datadir", - "pytest-xdist", - "coverage[toml]", - "coveralls", + "coverage[toml]", + "coveralls", + "pytest", + "pytest-cov", + "pytest-datadir", + "pytest-xdist", ] [project.scripts] babelize = "babelizer.cli:babelize" +[build-system] +requires = [ + "setuptools", + "wheel", +] +build-backend = "setuptools.build_meta" + [tool.setuptools] include-package-data = true +[tool.setuptools.dynamic.readme] +file = "README.rst" +content-type = "text/x-rst" + +[tool.setuptools.dynamic.version] +attr = "babelizer._version.__version__" + [tool.setuptools.package-data] babelizer = [ - "data/*", + "data/*", ] [tool.setuptools.packages.find] -where = ["."] -include = ["babelizer*"] +where = [ + ".", +] +include = [ + "babelizer*", +] -[tool.setuptools.dynamic] -readme = {file = ["README.rst", "CREDITS.rst", "CHANGES.rst", "LICENSE.rst"]} -version = {attr = "babelizer._version.__version__"} +[tool.black] +line-length = 88 +exclude = """ +( + babelizer/data + | external +) +""" + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +combine_as_imports = true +line_length = 88 +skip = [ + "babelizer/data", +] [tool.pytest.ini_options] minversion = "6.0" -testpaths = ["babelizer", "tests"] -norecursedirs = [".*", "*.egg*", "build", "dist"] -# usefixtures = suppress_resource_warning +testpaths = [ + "babelizer", + "tests", +] +norecursedirs = [ + ".*", + "*.egg*", + "build", + "dist", +] addopts = """ --ignore setup.py --ignore babelizer/data @@ -118,26 +159,9 @@ addopts = """ doctest_optionflags = [ "NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL", - "ALLOW_UNICODE" + "ALLOW_UNICODE", ] -[tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -combine_as_imports = true -line_length = 88 -skip = ["babelizer/data"] - -[tool.black] -line-length = 88 -exclude = ''' -( - babelizer/data - | external -) -''' - [tool.towncrier] directory = "news" package = "babelizer" From 510e30b1a5219a3e289d3230e02b450f551653ac Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 11:48:54 -0700 Subject: [PATCH 02/19] run ci with python 3.10+ --- .github/workflows/build-test-ci.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/lint.yml | 4 ++-- noxfile.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/build-test-ci.yml index a52b5c9e..92315434 100644 --- a/.github/workflows/build-test-ci.yml +++ b/.github/workflows/build-test-ci.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.9", "3.10"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e051f467..565b221e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -38,7 +38,7 @@ jobs: - uses: conda-incubator/setup-miniconda@v2 with: auto-update-conda: true - python-version: 3.9 + python-version: 3.12 channels: conda-forge channel-priority: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7c719fae..5ac6b4ab 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.12 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: 3.12 - name: Lint run: | diff --git a/noxfile.py b/noxfile.py index 331681dc..29f87bef 100644 --- a/noxfile.py +++ b/noxfile.py @@ -9,7 +9,7 @@ PROJECT = "babelizer" ROOT = pathlib.Path(__file__).parent ALL_LANGS = {"c", "cxx", "fortran", "python"} -PYTHON_VERSIONS = ["3.9", "3.10", "3.11"] +PYTHON_VERSIONS = ["3.10", "3.11", "3.12"] @nox.session(python=PYTHON_VERSIONS) From 8569b30f0577e34cf96fe9aa923386dfedc0f46e Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 11:49:47 -0700 Subject: [PATCH 03/19] run pyupgrade with 3.10+ --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd8f9928..2d732b1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: rev: v2.34.0 hooks: - id: pyupgrade - args: [--py38-plus] + args: [--py310-plus] exclude: ^babelizer/data - repo: https://github.com/PyCQA/isort From f2da9f2bfe4b5b4e1489d9786d031f5a66ff73d2 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 11:56:02 -0700 Subject: [PATCH 04/19] update pre-commit hooks --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d732b1a..170e3ef5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.2.0 hooks: - id: black name: black @@ -25,7 +25,7 @@ repos: exclude: ^babelizer/data - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: @@ -35,21 +35,21 @@ repos: exclude: ^babelizer/data - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v3.15.1 hooks: - id: pyupgrade args: [--py310-plus] exclude: ^babelizer/data - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort files: \.py$ exclude: ^babelizer/data - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: check-builtin-literals exclude: ^babelizer/data @@ -66,7 +66,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/PyCQA/pydocstyle - rev: 6.1.1 + rev: 6.3.0 hooks: - id: pydocstyle files: babelizer/.*\.py$ @@ -77,7 +77,7 @@ repos: additional_dependencies: [".[toml]"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v1.8.0 hooks: - id: mypy additional_dependencies: [types-all] From 3b4dd827cdc1ce9e4bf98fd86d044cda7e9ad372 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 11:56:48 -0700 Subject: [PATCH 05/19] remove lint --- babelizer/__init__.py | 1 + babelizer/cli.py | 17 +++++++++-------- babelizer/metadata.py | 9 +++++++-- babelizer/render.py | 1 + babelizer/utils.py | 1 + docs/source/examples/heatc_ex.py | 7 ++++--- docs/source/examples/pymt_heatc_ex.py | 1 + requirements.py | 6 +++--- tests/test_cli.py | 1 + 9 files changed, 28 insertions(+), 16 deletions(-) diff --git a/babelizer/__init__.py b/babelizer/__init__.py index 78120efc..546781d0 100644 --- a/babelizer/__init__.py +++ b/babelizer/__init__.py @@ -1,4 +1,5 @@ """The *babelizer*.""" + from ._version import __version__ __all__ = ["__version__"] diff --git a/babelizer/cli.py b/babelizer/cli.py index a85bd3dd..1659b8f5 100644 --- a/babelizer/cli.py +++ b/babelizer/cli.py @@ -1,4 +1,5 @@ """The command line interface to the babelizer.""" + import fnmatch import os import pathlib @@ -359,9 +360,7 @@ def ask_until_done(text): } libraries = {} - if (not prompt) or any( - [x is not None for x in (name, library, header, entry_point)] - ): + if (not prompt) or any(x is not None for x in (name, library, header, entry_point)): babelized_class = name or ask("Name of babelized class", default="") libraries[babelized_class] = { "language": language, @@ -385,11 +384,13 @@ def ask_until_done(text): libraries[babelized_class] = { "language": language, "library": ask(f"[{babelized_class}] Name of library to babelize"), - "header": ask( - f"[{babelized_class}] Name of header file containing BMI class " - ) - if language != "python" - else "__UNUSED__", + "header": ( + ask( + f"[{babelized_class}] Name of header file containing BMI class " + ) + if language != "python" + else "__UNUSED__" + ), "entry_point": ask(f"[{babelized_class}] Name of BMI class "), } if not yes("Add another library?", default=False): diff --git a/babelizer/metadata.py b/babelizer/metadata.py index 1de02e78..bbcfc14b 100644 --- a/babelizer/metadata.py +++ b/babelizer/metadata.py @@ -1,4 +1,5 @@ """Library metadata used by the babelizer to wrap libraries.""" + import pathlib import re import warnings @@ -142,7 +143,9 @@ def __init__( Information about how to set up continuous integration. """ if plugin is not None: - warnings.warn("use 'package' instead of 'plugin'", DeprecationWarning) + warnings.warn( + "use 'package' instead of 'plugin'", DeprecationWarning, stacklevel=2 + ) if package is not None: raise ValueError("specify one of 'package' or 'plugin', not both") package = plugin @@ -295,7 +298,9 @@ def validate(config): ), optional={}, ) - warnings.warn("use 'package' instead of 'plugin'", DeprecationWarning) + warnings.warn( + "use 'package' instead of 'plugin'", DeprecationWarning, stacklevel=2 + ) @staticmethod def _handle_old_style_entry_points(library): diff --git a/babelizer/render.py b/babelizer/render.py index 34f13919..c8069ac1 100644 --- a/babelizer/render.py +++ b/babelizer/render.py @@ -1,4 +1,5 @@ """Render a new babelized project.""" + import contextlib import os import pathlib diff --git a/babelizer/utils.py b/babelizer/utils.py index e5779abd..b9169509 100644 --- a/babelizer/utils.py +++ b/babelizer/utils.py @@ -1,4 +1,5 @@ """Utility functions used by the babelizer.""" + import pathlib import subprocess import sys diff --git a/docs/source/examples/heatc_ex.py b/docs/source/examples/heatc_ex.py index 28ca05c9..d6c31f23 100644 --- a/docs/source/examples/heatc_ex.py +++ b/docs/source/examples/heatc_ex.py @@ -1,4 +1,5 @@ """An example of running the heatc model through its BMI.""" + import numpy as np from pymt_heatc import HeatModel @@ -30,10 +31,10 @@ print(" - shape:", grid_shape) grid_size = m.get_grid_size(grid_id) print(" - size:", grid_size) -grid_spacing = np.empty(grid_rank, dtype=np.float) +grid_spacing = np.empty(grid_rank, dtype=np.float64) m.get_grid_spacing(grid_id, grid_spacing) print(" - spacing:", grid_spacing) -grid_origin = np.empty(grid_rank, dtype=np.float) +grid_origin = np.empty(grid_rank, dtype=np.float64) m.get_grid_origin(grid_id, grid_origin) print(" - origin:", grid_origin) print(" - variable type:", m.get_var_type(var_name)) @@ -42,7 +43,7 @@ print(" - nbytes:", m.get_var_nbytes(var_name)) # Get the initial temperature values. -val = np.empty(grid_shape, dtype=np.float) +val = np.empty(grid_shape, dtype=np.float64) m.get_value(var_name, val) print(" - initial values (gridded):") print(val.reshape(np.roll(grid_shape, 1))) diff --git a/docs/source/examples/pymt_heatc_ex.py b/docs/source/examples/pymt_heatc_ex.py index 44d79546..85f27694 100644 --- a/docs/source/examples/pymt_heatc_ex.py +++ b/docs/source/examples/pymt_heatc_ex.py @@ -1,4 +1,5 @@ """Run the heat model in pymt.""" + from pymt.models import HeatModel # Instantiate the component and get its name. diff --git a/requirements.py b/requirements.py index dbe42cd7..f7b8d501 100755 --- a/requirements.py +++ b/requirements.py @@ -22,9 +22,9 @@ def requirements(extras): if extras: optional_dependencies = project.get("optional-dependencies", {}) for extra in extras: - dependencies[ - f"[project.optional-dependencies.{extra}]" - ] = optional_dependencies[extra] + dependencies[f"[project.optional-dependencies.{extra}]"] = ( + optional_dependencies[extra] + ) else: dependencies["[project.dependencies]"] = project["dependencies"] diff --git a/tests/test_cli.py b/tests/test_cli.py index ba9d3512..eec00562 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,4 +1,5 @@ """Test the babelizer command-line interface""" + from click.testing import CliRunner from babelizer.cli import babelize From c3ad0e20b6a79d7c2d4d68595ef13fbee73ad328 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 11:59:42 -0700 Subject: [PATCH 06/19] move coverage, zest.releaser config to pyproject.toml --- pyproject.toml | 8 ++++++++ setup.cfg | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7c2ceceb..821c8b8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,6 +125,10 @@ exclude = """ ) """ +[tool.coverage.run] +omit = "*/babelizer/data/*" +relative_files = true + [tool.isort] multi_line_output = 3 include_trailing_comma = true @@ -171,3 +175,7 @@ underlines = "-^\"" issue_format = "`#{issue} `_" title_format = "{version} ({project_date})" wrap = true + +[tool.zest-releaser] +tag-format = "v{version}" +python-file-with-version = "babelizer/_version.py" diff --git a/setup.cfg b/setup.cfg index 911da7e0..23f551ef 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,11 +5,3 @@ ignore = E501 W503 max-line-length = 88 - -[zest.releaser] -tag-format = v{version} -python-file-with-version = babelizer/_version.py - -[coverage:run] -omit = */babelizer/data/* -relative_files = True From 602f4b37737d30ef40a6ccd8c6be4a624de41fe0 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 12:13:26 -0700 Subject: [PATCH 07/19] remove uses of pkg_resources --- babelizer/cli.py | 12 +++++++++--- babelizer/render.py | 9 +++++++-- docs/source/conf.py | 4 ++-- pyproject.toml | 1 + 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/babelizer/cli.py b/babelizer/cli.py index 1659b8f5..a408e6b8 100644 --- a/babelizer/cli.py +++ b/babelizer/cli.py @@ -3,12 +3,18 @@ import fnmatch import os import pathlib +import sys import tempfile from functools import partial import click import git -import pkg_resources + +if sys.version_info >= (3, 12): # pragma: no cover (PY12+) + import importlib.resources as importlib_resources +else: # pragma: no cover (= (3, 12): # pragma: no cover (PY12+) + import importlib.resources as importlib_resources +else: # pragma: no cover (=5", "pyyaml", "tomlkit", From 2409137aebd436d67f0e88d17d680317ded87a41 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 12:17:10 -0700 Subject: [PATCH 08/19] change coverage.omit to a list of strings --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d9ba764a..7ebf617c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,7 +127,9 @@ exclude = """ """ [tool.coverage.run] -omit = "*/babelizer/data/*" +omit = [ + "*/babelizer/data/*", +] relative_files = true [tool.isort] From 813902ae4cf77d18b3171cb917f6e8e40435e2b6 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 12:35:48 -0700 Subject: [PATCH 09/19] update the bmi-example-python submodule --- external/bmi-example-python | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bmi-example-python b/external/bmi-example-python index 1329f473..b0a471c2 160000 --- a/external/bmi-example-python +++ b/external/bmi-example-python @@ -1 +1 @@ -Subproject commit 1329f473ec5130ae37547f509137dd63bb957e73 +Subproject commit b0a471c2f364a66f167b3209203a6991f39d97f2 From 7b91576db9438e403b3803c0da442a98cd80d553 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 12:44:17 -0700 Subject: [PATCH 10/19] turn off fast fail --- .github/workflows/build-test-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/build-test-ci.yml index 92315434..e2628629 100644 --- a/.github/workflows/build-test-ci.yml +++ b/.github/workflows/build-test-ci.yml @@ -18,6 +18,7 @@ jobs: shell: bash -l {0} strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest] python-version: ["3.10", "3.11", "3.12"] From 5193552dbf41dadee14b95d55972f5d4e513e500 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 12:52:30 -0700 Subject: [PATCH 11/19] remove uses of pkg_resources from template files --- .../{{cookiecutter.package_name}}/__init__.py | 5 ++--- .../{{cookiecutter.package_name}}/bmi.py | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) 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..3f24fe18 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/__init__.py +++ b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/__init__.py @@ -1,8 +1,7 @@ #! /usr/bin/env python -import pkg_resources +import importlib.metadata - -__version__ = pkg_resources.get_distribution("{{ cookiecutter.package_name }}").version +__version__ = importlib.metadata.version("{{ cookiecutter.package_name }}") from .bmi import ( diff --git a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py index a7026bc0..47e92afe 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py +++ b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py @@ -10,7 +10,11 @@ from .lib import {{ classes|join(', ') }} {%- else %} -import pkg_resources +if sys.version_info >= (3, 12): # pragma: no cover (PY12+) + import importlib.resources as importlib_resources +else: # pragma: no cover ( Date: Mon, 4 Mar 2024 13:03:18 -0700 Subject: [PATCH 12/19] add missing import of sys --- .../{{cookiecutter.package_name}}/bmi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py index 47e92afe..7b97d80a 100644 --- a/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py +++ b/babelizer/data/{{cookiecutter.package_name}}/{{cookiecutter.package_name}}/bmi.py @@ -10,6 +10,7 @@ from .lib import {{ classes|join(', ') }} {%- else %} +import sys if sys.version_info >= (3, 12): # pragma: no cover (PY12+) import importlib.resources as importlib_resources else: # pragma: no cover ( Date: Mon, 4 Mar 2024 13:29:23 -0700 Subject: [PATCH 13/19] add a separate workflow to test langs in parallel --- .github/workflows/build-test-ci.yml | 14 -------- .github/workflows/test-langs.yml | 51 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/test-langs.yml diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/build-test-ci.yml index e2628629..6188417d 100644 --- a/.github/workflows/build-test-ci.yml +++ b/.github/workflows/build-test-ci.yml @@ -32,26 +32,12 @@ jobs: with: python-version: ${{ matrix.python-version }} - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - mamba-version: "*" - channels: conda-forge - channel-priority: true - - name: Install dependencies run: python -m pip install nox tomli - - name: Install compilers - run: mamba install c-compiler cxx-compiler fortran-compiler cmake - - name: Run the tests run: nox --session test test-cli --python ${{ matrix.python-version }} --verbose - - name: Run the language tests - run: nox --non-interactive --error-on-missing-interpreter --session test-langs --python ${{ matrix.python-version }} --verbose - - name: Coveralls if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' uses: AndreMiras/coveralls-python-action@v20201129 diff --git a/.github/workflows/test-langs.yml b/.github/workflows/test-langs.yml new file mode 100644 index 00000000..30f5c35f --- /dev/null +++ b/.github/workflows/test-langs.yml @@ -0,0 +1,51 @@ +name: Build/Test CI + +on: [push, pull_request] + +jobs: + build-and-test: + # 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: ${{ matrix.os }} + + defaults: + run: + shell: bash -l {0} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ["3.10", "3.11", "3.12"] + language: ["c", "cxx", "python", "fortran"] + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ matrix.python-version }} + mamba-version: "*" + channels: conda-forge + channel-priority: true + + - name: Install dependencies + run: python -m pip install nox tomli + + - name: Install compilers + run: mamba install c-compiler cxx-compiler fortran-compiler cmake + + - name: Run the language tests + run: nox -s "test-langs-${{ matrix.python-version }}(lang='${{ matrix.language }}')" --python ${{ matrix.python-version }} --verbose + + - name: Coveralls + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' + uses: AndreMiras/coveralls-python-action@v20201129 From 7f5912727632e203d3100ebec73477581f4dbcf1 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 13:31:10 -0700 Subject: [PATCH 14/19] change workflow name --- .github/workflows/test-langs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-langs.yml b/.github/workflows/test-langs.yml index 30f5c35f..0149b9f0 100644 --- a/.github/workflows/test-langs.yml +++ b/.github/workflows/test-langs.yml @@ -1,9 +1,9 @@ -name: Build/Test CI +name: Test languages on: [push, pull_request] jobs: - build-and-test: + test-langs: # 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. From d289f1ea869bcb02523febdf823dfc2912157da9 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 13:39:22 -0700 Subject: [PATCH 15/19] install cmake into nox environment --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 29f87bef..662698e6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -42,7 +42,7 @@ def test_langs(session: nox.session, lang) -> None: build_examples(session, lang) - session.conda_install("pip", "bmi-tester>=0.5.4") + session.conda_install("pip", "bmi-tester>=0.5.4", "cmake") session.install(".[testing]") with session.chdir(tmpdir): From 8476bad24031fb77414ed590cb0965757b90e351 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 13:45:17 -0700 Subject: [PATCH 16/19] allow newer version of setuptools to build generated project --- 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 437aaaa4..80670bd5 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"] [tool.pytest.ini_options] minversion = "5.0" From 8864ce62b5b75ea894d8ed7c6816fd7335797c7d Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 14:02:35 -0700 Subject: [PATCH 17/19] don't install cmake with compilers --- .github/workflows/test-langs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-langs.yml b/.github/workflows/test-langs.yml index 0149b9f0..2b32dd0e 100644 --- a/.github/workflows/test-langs.yml +++ b/.github/workflows/test-langs.yml @@ -41,7 +41,7 @@ jobs: run: python -m pip install nox tomli - name: Install compilers - run: mamba install c-compiler cxx-compiler fortran-compiler cmake + run: mamba install c-compiler cxx-compiler fortran-compiler - name: Run the language tests run: nox -s "test-langs-${{ matrix.python-version }}(lang='${{ matrix.language }}')" --python ${{ matrix.python-version }} --verbose From ab51ccfec2f2fc818019047af0f2db8f7a96a419 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 14:34:40 -0700 Subject: [PATCH 18/19] add news fragment --- news/88.misc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 news/88.misc diff --git a/news/88.misc b/news/88.misc new file mode 100644 index 00000000..37f8fac2 --- /dev/null +++ b/news/88.misc @@ -0,0 +1,2 @@ + +Added support for Python 3.12 and dropped support for Python less than 3.10. From 766b93b731c0bb81519a9f2cb723451d9576b1f6 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 4 Mar 2024 14:35:44 -0700 Subject: [PATCH 19/19] rename workflow that tests the cli --- .github/workflows/{build-test-ci.yml => test-cli.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{build-test-ci.yml => test-cli.yml} (96%) diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/test-cli.yml similarity index 96% rename from .github/workflows/build-test-ci.yml rename to .github/workflows/test-cli.yml index 6188417d..cb3a1f76 100644 --- a/.github/workflows/build-test-ci.yml +++ b/.github/workflows/test-cli.yml @@ -1,9 +1,9 @@ -name: Build/Test CI +name: Test CLI on: [push, pull_request] jobs: - build-and-test: + test-cli: # 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.