diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ece0d8df..d7e090b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ env: jobs: build: - name: Build (${{ matrix.python-version }}, ${{ matrix.os }}) + name: Build (${{ matrix.python-version }}, ${{ matrix.os }}), ${{ matrix.env }} runs-on: ${{ matrix.os }} defaults: run: @@ -27,7 +27,15 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] - python-version: ["3.10", "3.12"] + python-version: ["3.10", "3.13"] + env: [""] + include: + - env: "all-min-deps" + python-version: "3.10" + os: ubuntu-latest + - env: "no-optional-deps" + python-version: "3.13" + os: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -35,10 +43,22 @@ jobs: - name: Set environment variables run: | echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV + if [[ "${{ matrix.env }}" == "" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment.yml" >> $GITHUB_ENV + fi + if [[ "${{ matrix.env }}" == "no-optional-deps" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment-no-optional-deps.yml" >> $GITHUB_ENV + fi + if [[ "${{ matrix.env }}" == "all-min-deps" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment-all-min-deps.yml" >> $GITHUB_ENV + fi - name: Set up conda environment uses: mamba-org/setup-micromamba@v2 with: - environment-file: ci/environment.yml + environment-file: ${{ env.CONDA_ENV_FILE }} environment-name: cf_xarray_test cache-environment: true create-args: >- @@ -58,31 +78,6 @@ jobs: name: codecov-umbrella fail_ci_if_error: false - no-optional-deps: - name: no-optional-deps - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v4 - with: - # need to fetch all tags to get a correct version - fetch-depth: 0 # fetch all branches and tags - - name: Set up conda environment - uses: mamba-org/setup-micromamba@v2 - with: - environment-file: ci/environment-no-optional-deps.yml - environment-name: cf_xarray_test - cache-environment: true - - name: Install cf_xarray - run: | - python -m pip install --no-deps -e . - - name: Run Tests - shell: bash -l {0} - run: | - pytest -n 2 - mypy: name: mypy runs-on: "ubuntu-latest" @@ -91,7 +86,7 @@ jobs: shell: bash -l {0} strategy: matrix: - python-version: ["3.10", "3.12"] + python-version: ["3.10", "3.13"] steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index c5efd597..333305ed 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.12"] + python-version: ["3.13"] steps: - uses: actions/checkout@v4 with: diff --git a/cf_xarray/__init__.py b/cf_xarray/__init__.py index cc038830..6800c2c7 100644 --- a/cf_xarray/__init__.py +++ b/cf_xarray/__init__.py @@ -1,3 +1,7 @@ +import xarray +from packaging.version import Version + +from . import geometry as geometry from . import sgrid # noqa from .accessor import CFAccessor # noqa from .coding import ( # noqa @@ -9,6 +13,7 @@ from .options import set_options # noqa from .utils import _get_version -from . import geometry, groupers # noqa +if Version(xarray.__version__) >= Version("2024.07.0"): + from . import groupers as groupers __version__ = _get_version() diff --git a/cf_xarray/tests/test_groupers.py b/cf_xarray/tests/test_groupers.py index 8c87d695..489d0cf8 100644 --- a/cf_xarray/tests/test_groupers.py +++ b/cf_xarray/tests/test_groupers.py @@ -3,6 +3,8 @@ import xarray as xr from xarray.testing import assert_identical +pytest.importorskip("xarray", "2024.07.0") + from cf_xarray.datasets import flag_excl from cf_xarray.groupers import FlagGrouper diff --git a/ci/environment-all-min-deps.yml b/ci/environment-all-min-deps.yml new file mode 100644 index 00000000..8b431eb7 --- /dev/null +++ b/ci/environment-all-min-deps.yml @@ -0,0 +1,24 @@ +name: cf_xarray_test +channels: + - conda-forge +dependencies: + - pytest-cov + - pytest + - pytest-xdist + - dask + - flox + - lxml + - matplotlib-base + - netcdf4 + - pandas + - pint==0.19 + - pooch + - regex + - rich + - pooch + - scipy + - shapely + - xarray==2023.09.0 + - pip + - pip: + - pytest-pretty diff --git a/pyproject.toml b/pyproject.toml index f167b774..2269b133 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,9 +14,10 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dependencies = [ - "xarray>=2022.03.0", + "xarray>=2023.09.0", ] dynamic = ["version"] @@ -32,7 +33,7 @@ changelog = "https://cf-xarray.readthedocs.io/en/latest/whats-new.html" [build-system] requires = [ # xarray is need for dynamic version string - "xarray>=2022.03.0", + "xarray>=2023.09.0", "setuptools>=45", "setuptools_scm[toml]>=6.2", ]