Skip to content

Commit

Permalink
Merge pull request #35 from csdms/mdpiper/update-for-py312
Browse files Browse the repository at this point in the history
Updates for Python 3.12
  • Loading branch information
mdpiper authored Dec 15, 2023
2 parents 23b9bfe + e5f5f4c commit cf1ee72
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 45 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: psf/black@stable
with:
args: ". --check"

- name: Format
run: |
pip install black
black .
9 changes: 4 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.11"
environment-file: environment.yml
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true

- name: Install requirements
- name: Show conda installation info
run: |
mamba install --file=requirements.txt --file=requirements-docs.txt
mamba info
mamba list
- name: Install package
run: |
pip install -e .
make install
- name: Build documentation
run: |
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
Expand All @@ -38,20 +38,15 @@ jobs:
mamba info
mamba list
- name: Install requirements
run: |
mamba install --file=requirements.txt --file=requirements-testing.txt
mamba list
- name: Build and install package
run: |
pip install -e .
make install
- name: Test
run: |
python -c 'import bmi_tester; print(bmi_tester.__version__)'
pytest --cov=bmi_tester --cov-report=xml:$(pwd)/coverage.xml -vvv
- name: Coveralls
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
uses: AndreMiras/coveralls-python-action@v20201129
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: AndreMiras/coveralls-python-action@develop
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog for bmi-tester
0.5.6 (unreleased)
------------------

- Nothing changed yet.
- Move static metadata to setup.cfg; update requirements; update CI workflows (#32)
- Updates for Python 3.12 (#35)


0.5.5 (2021-03-31)
Expand Down
11 changes: 10 additions & 1 deletion CREDITS.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Credits
=======

* Eric Hutton
Author
------

* Eric Hutton <[email protected]>

Contributors
------------

* Eric Hutton
* Mark Piper
* Scott Stewart
* Mike Taves
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT"
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
clean: clean-build clean-docs clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
rm -fr build/
Expand All @@ -38,6 +38,11 @@ clean-build: ## remove build artifacts
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-docs: ## remove artifacts from docs build
rm -f docs/api/bmi_tester.rst
rm -f docs/api/modules.rst
$(MAKE) -C docs clean

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
Expand Down Expand Up @@ -69,11 +74,9 @@ coverage: ## check code coverage quickly with the default Python
coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/api/bmi_tester.rst
rm -f docs/api/modules.rst
docs: clean-docs ## generate Sphinx HTML documentation, including API docs
sphinx-apidoc --force -o docs/api bmi_tester bmi_tester/tests/** bmi_tester/bootstrap/**
$(MAKE) -C docs clean html
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html

servedocs: docs ## compile the docs watching for changes
Expand Down
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bmi-tester: Test Basic Model Interface implementations
======================================================

|Build Status| |Documentation Status| |Coverage Status| |Conda Version|
|Conda Installation| |Conda Downloads|
|Conda Downloads|

About
-----
Expand Down Expand Up @@ -119,7 +119,5 @@ Links
:target: https://coveralls.io/github/csdms/bmi-tester?branch=master
.. |Conda Version| image:: https://anaconda.org/conda-forge/bmi-tester/badges/version.svg
:target: https://anaconda.org/conda-forge/bmi-tester
.. |Conda Installation| image:: https://anaconda.org/conda-forge/bmi-tester/badges/installer/conda.svg
:target: https://conda.anaconda.org/conda-forge
.. |Conda Downloads| image:: https://anaconda.org/conda-forge/bmi-tester/badges/downloads.svg
:target: https://anaconda.org/conda-forge/bmi-tester
5 changes: 2 additions & 3 deletions bmi_tester/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib.metadata import version

from .api import (
check_bmi,
Expand All @@ -7,11 +7,10 @@
check_unit_is_valid,
)

__version__ = pkg_resources.get_distribution("bmi_tester").version
__version__ = version("bmi-tester")
__all__ = [
"check_bmi",
"check_unit_is_valid",
"check_unit_is_time",
"check_unit_is_dimensionless",
]
del pkg_resources
4 changes: 2 additions & 2 deletions bmi_tester/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import importlib
import os
from distutils.version import StrictVersion
from packaging.version import Version

import pytest
from model_metadata.scripting import as_cwd, cp
Expand Down Expand Up @@ -54,7 +54,7 @@ def load_component(entry_point):
INPUT_FILE = os.environ.get("BMITEST_INPUT_FILE", None)
# BMI_VERSION_STRING = os.environ.get("BMI_VERSION_STRING", "1.1")
BMI_VERSION_STRING = os.environ.get("BMI_VERSION_STRING", "2.0")
BMI_VERSION = StrictVersion(BMI_VERSION_STRING)
BMI_VERSION = Version(BMI_VERSION_STRING)


def all_grids(bmi, gtype=None):
Expand Down
4 changes: 2 additions & 2 deletions bmi_tester/tests/stage_3/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from packaging.version import Version

import numpy as np
import pytest
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_get_grid_type(initialized_bmi, gid):


@pytest.mark.skipif(
BMI_VERSION < StrictVersion("2.0"), reason="get_grid_node_count is BMI 2.0"
BMI_VERSION < Version("2.0"), reason="get_grid_node_count is BMI 2.0"
)
# @pytest.mark.dependency()
def test_get_grid_node_count(initialized_bmi, gid):
Expand Down
6 changes: 3 additions & 3 deletions bmi_tester/tests/stage_3/test_value.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import StrictVersion
from packaging.version import Version

import numpy as np
import pytest
Expand All @@ -10,7 +10,7 @@
# from pytest_dependency import depends


BMI_VERSION = StrictVersion(BMI_VERSION_STRING)
BMI_VERSION = Version(BMI_VERSION_STRING)

BAD_VALUE = {"f": np.nan, "i": -999, "u": 0}

Expand All @@ -25,7 +25,7 @@
def test_get_var_location(initialized_bmi, var_name):
"""Test for get_var_location"""
# assert False
if BMI_VERSION < "1.1":
if BMI_VERSION < Version("1.1"):
pytest.skip(
"testing BMIv{ver}: get_var_location was introduced in BMIv1.1".format(
ver=BMI_VERSION
Expand Down
6 changes: 4 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ channels:
- conda-forge
dependencies:
- pip
- udunits2
- pip:
- -r file:requirements.txt
- -r file:requirements-docs.txt
- -r requirements.txt
- -r requirements-docs.txt
- -r requirements-testing.txt
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ keywords = [
"csdms",
"model",
"python",
"testing",
]
license = {file = "LICENSE"}
classifiers = [
Expand All @@ -31,6 +32,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Physics",
]
Expand All @@ -50,6 +52,7 @@ dynamic = ["readme"]
dev = [
"black",
"flake8",
"isort",
]
testing = [
"coveralls",
Expand All @@ -66,10 +69,10 @@ build = [
]

[project.urls]
homepage = "https://csdms.colorado.edu"
documentation = "https://csdms.colorado.edu"
repository = "https://github.com/csdms/bmi-tester"
changelog = "https://github.com/csdms/bmi-tester/blob/master/CHANGES.rst"
Homepage = "https://csdms.colorado.edu"
Documentation = "https://bmi-tester.readthedocs.io/"
Repository = "https://github.com/csdms/bmi-tester"
Changelog = "https://github.com/csdms/bmi-tester/blob/master/CHANGES.rst"

[project.scripts]
bmi-test = "bmi_tester.bmipytest:main"
Expand All @@ -88,7 +91,7 @@ addopts = """
--ignore bmi_tester/bootstrap
--ignore bmi_tester/tests
--tb native
--strict
--strict-markers
--durations 16
--doctest-modules
-vvv
Expand Down

0 comments on commit cf1ee72

Please sign in to comment.