-
Notifications
You must be signed in to change notification settings - Fork 83
Modernise setup by moving from setup.py to pyproject.toml #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f6945c7
99a11cc
82326cb
cfbe38d
4f1a6b2
e767539
0adf34f
4fc70d5
c1fa492
4d1b14b
957f737
4071012
0493f48
6ec7cda
29ab0c2
f509383
532ef99
17f631d
456872b
36b2068
f247560
fe2b203
dd1c47a
4299271
b530e05
67067fa
d3b91e3
1f8fc3a
37efc79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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 | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, I think, would be a |
||
| - 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 | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,20 +5,23 @@ Changelog for cfgrib | |||||||
| unreleased | ||||||||
| ---------- | ||||||||
|
|
||||||||
| - Deprecating setuptools in favor of hatchling and pyproject.toml. | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
and then this PR does more things, which might need to be documented in the changelog:
|
||||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||||||||
| --------------------- | ||||||||
|
|
||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file got deleted