Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f6945c7
move setup completely to pyproject.toml
observingClouds Nov 28, 2025
99a11cc
adjust formatting
observingClouds Nov 28, 2025
82326cb
set README
observingClouds Nov 28, 2025
cfbe38d
add black config
observingClouds Nov 28, 2025
4f1a6b2
document changes
observingClouds Nov 28, 2025
e767539
Merge README and CHANGELOG to one repo description
observingClouds Dec 25, 2025
0adf34f
Merge remote-tracking branch 'origin/master' into pr/438
observingClouds Dec 25, 2025
4fc70d5
add cfgrib to build
observingClouds Dec 25, 2025
c1fa492
move test dependencies to correct group
observingClouds Dec 25, 2025
4d1b14b
run pytest against packages
observingClouds Dec 25, 2025
957f737
Merge branch 'maint/pyproject' of github.com:observingClouds/cfgrib i…
observingClouds Dec 25, 2025
4071012
update python classifiers
observingClouds Dec 25, 2025
0493f48
update tox
observingClouds Dec 25, 2025
6ec7cda
get necessary tox.ini
observingClouds Dec 25, 2025
29ab0c2
ignore wheel having multple toplevel entries
observingClouds Dec 25, 2025
f509383
get tests
observingClouds Dec 25, 2025
532ef99
fix casting error of datetime64/timedelta64
observingClouds Dec 25, 2025
17f631d
allow for floating point differences
observingClouds Dec 25, 2025
456872b
fix tests by restricting xarray
observingClouds Dec 25, 2025
36b2068
consolidate environments
observingClouds Dec 25, 2025
f247560
change weekly test to run actual test with latest environment
observingClouds Dec 25, 2025
fe2b203
fix weekly test syntax
observingClouds Dec 25, 2025
dd1c47a
convert tox env to hatch in pyproject
observingClouds Dec 25, 2025
4299271
use core python package
observingClouds Dec 25, 2025
b530e05
add build docs gh action
observingClouds Dec 25, 2025
67067fa
apply precommit
observingClouds Dec 25, 2025
d3b91e3
Merge remote-tracking branch 'fork/maint/pyproject' into maint/pyproject
observingClouds Dec 25, 2025
1f8fc3a
move coverage report to extra job; add precommit autofix
observingClouds Dec 25, 2025
37efc79
revert adding precommit action
observingClouds Dec 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,32 @@ jobs:
with:
cfgrib: ecmwf/cfgrib@${{ github.event.pull_request.head.sha || github.sha }}
secrets: inherit

# Coverage report
coverage:
name: Coverage Report
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Run tests with coverage
run: |
uv run --group qc pytest -v --cov=cfgrib --cov=cf2cdm --cov-report=html --cache-clear

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report-html
path: htmlcov/
retention-days: 30
44 changes: 44 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Documentation

on:
# Trigger on push to master or develop
push:
branches:
- 'master'
- 'develop'

# Trigger on pull request
pull_request: ~

# Allow manual trigger
workflow_dispatch: ~

jobs:
build-docs:
name: Build Sphinx Documentation
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install dependencies and build docs
run: |
uv run --group docs sphinx-build -W -b html docs build/sphinx/html

- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation-html
path: build/sphinx/html/
retention-days: 30
73 changes: 73 additions & 0 deletions .github/workflows/packaging-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test Package

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- uses: hynek/build-and-inspect-python-package@v2.14.0
id: baipp

outputs:
# Used to define the matrix for tests below. The value is based on
# packaging metadata (trove classifiers).
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}

tests:
name: Tests on ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: build-package

strategy:
fail-fast: false
matrix:
# Created by the build-and-inspect-python-package action above.
python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }}

env:
PYTHON: ${{ matrix.python-version }}

steps:
- name: Get tox file
uses: actions/checkout@v6
with:
sparse-checkout: |
tox.ini
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file got deleted

tests/
persist-credentials: false
- name: Download pre-built packages
uses: actions/download-artifact@v6
with:
name: Packages
path: dist
- run: |
tar xf dist/*.tar.gz --strip-components=1
rm -rf cfgrib
rm -rf cf2cdm
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: hynek/setup-cached-uv@v2

- name: Run tests against whl
run: |
uv run --with dist/*.whl --group test --python ${{ matrix.python-version }} \
pytest -v --cache-clear

- name: Run tests against sdist
run: |
uv run --with dist/*.tar.gz --group test --python ${{ matrix.python-version }} \
pytest -v --cache-clear
35 changes: 7 additions & 28 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,17 @@ on:

jobs:
weekly:
runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 5
fail-fast: false
matrix:
os: [ubuntu]
python: [3.7, 3.8]
extras: ['']
include:
- os: macos
python: 3.8
- os: windows
python: 3.8
- os: ubuntu
python: 3.9
extras: -minimal
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
os: [windows-latest, ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: astral-sh/setup-uv@v5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you confirmed that uv can handle installing the ecCodes C library in addition to the ecCodes python package?

with:
auto-update-conda: true
python-version: ${{ matrix.python }}
activate-environment: ${{ matrix.os }}-${{ matrix.python }}${{ matrix.extras }}
environment-file: environment${{ matrix.extras }}.in.yml
- name: Export concrete dependencies
shell: bash -l {0}
run: |
conda env export --no-build -f tests/environment-${{ matrix.os }}-${{ matrix.python }}${{ matrix.extras }}.yml
git diff
Comment on lines -33 to -39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, I think, would be a uv compile step

- name: Archive environment-${{ matrix.os }}-${{ matrix.python }}${{ matrix.extras }}.yml
uses: actions/upload-artifact@v4
with:
name: environment-${{ matrix.os }}-${{ matrix.python }}${{ matrix.extras }}.yml
path: tests/environment-${{ matrix.os }}-${{ matrix.python }}${{ matrix.extras }}.yml
enable-cache: true
- name: Run test suite Python ${{ matrix.python-version }}
run: uv run --group tests pytest -v --cache-clear
9 changes: 6 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ Changelog for cfgrib
unreleased
----------

- Deprecating setuptools in favor of hatchling and pyproject.toml.
Copy link
Contributor

@DWesl DWesl Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing you do here will deprecate setuptools, which is still a valid build backend (unlike distutils, which was deprecated some years ago and has since been removed from Python). Among other things, setuptools is one of three backends that supports compiled extension modules. Hatchling, so far, only seems to support Cython extension modules.

I would then suggest:

Suggested change
- Deprecating setuptools in favor of hatchling and pyproject.toml.
- Move away from discouraged `setup.py` in favor of `pyproject.toml`,
and also replace setuptools with hatchling as the build backend

and then this PR does more things, which might need to be documented in the changelog:

  • overhaul CI test setup to drop Appveyor in favor of GitHub Actions
  • set default encoding for time variables
  • drop support and testing for Python<3.10
  • drop tox configuration

See `#438 <https://github.com/ecmwf/cfgrib/pull/438>`_.

- Setup and apply linters via pre-commit.
See `#439 <https://github.com/ecmwf/cfgrib/pull/439>`_.


0.9.15.1 (2025-09-30)
---------------------

- Fixed xarray.backends imports for compatibilty with recent versions of xarray.
See `#409 <https://github.com/ecmwf/cfgrib/pull/409>`_.

- Set default dtype for step to `timedelta64[ns]` for compatibilty with
future versions of xarray.
See `#427 <https://github.com/ecmwf/cfgrib/pull/427>`_.

- Fixed xarray.backends imports for compatibilty with recent versions of xarray.
See `#409 <https://github.com/ecmwf/cfgrib/pull/409>`_.

Comment on lines +18 to -21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you changed the order?


0.9.15.0 (2024-12-18)
---------------------
Expand Down
17 changes: 0 additions & 17 deletions appveyor.yml

This file was deleted.

18 changes: 18 additions & 0 deletions cfgrib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ def to_netcdf(
for var in ds.data_vars:
netcdf_kwargs["encoding"].setdefault(var, var_encoding)

# Add default encoding for time variables to avoid int64 casting issues
netcdf_kwargs.setdefault("encoding", {})
for var_name in ds.variables:
if var_name not in netcdf_kwargs["encoding"]:
var = ds[var_name]
# Check if variable has datetime-like or timedelta-like dtype
dtype_str = str(var.dtype)
if "datetime64" in dtype_str:
netcdf_kwargs["encoding"][var_name] = {
"units": "seconds since 1970-01-01",
"dtype": "int32",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, do you know what the GRIB format uses for these variables?

}
elif "timedelta64" in dtype_str:
netcdf_kwargs["encoding"][var_name] = {
"units": "seconds",
"dtype": "int32",
}

ds.to_netcdf(outpath, **netcdf_kwargs)


Expand Down
97 changes: 0 additions & 97 deletions ci/install_python.ps1

This file was deleted.

13 changes: 0 additions & 13 deletions ci/requirements-dev.txt

This file was deleted.

3 changes: 0 additions & 3 deletions ci/requirements-docs.in

This file was deleted.

Loading
Loading