|
| 1 | +# Upgrade Minimum Dependency Versions |
| 2 | + |
| 3 | +This skill upgrades xarray's minimum dependency versions to match the policy defined in `ci/policy.yaml`. |
| 4 | + |
| 5 | +## When to Use |
| 6 | + |
| 7 | +Run this skill when: |
| 8 | +- Preparing a new release that bumps minimum versions |
| 9 | +- The policy file has been updated and manifests need to catch up |
| 10 | +- `pixi run policy-min-versions` shows `<` for any packages |
| 11 | + |
| 12 | +## Steps |
| 13 | + |
| 14 | +### 1. Check Current Policy Status |
| 15 | + |
| 16 | +```bash |
| 17 | +pixi run policy-min-versions |
| 18 | +``` |
| 19 | + |
| 20 | +This shows a table with: |
| 21 | +- `=` means the version matches policy |
| 22 | +- `<` means the version needs to be upgraded |
| 23 | +- `>` means the version exceeds policy (usually fine) |
| 24 | + |
| 25 | +### 2. Update Version Pins in pixi.toml |
| 26 | + |
| 27 | +Update versions in these sections of `pixi.toml`: |
| 28 | + |
| 29 | +- `[feature.minimal.dependencies]` - for numpy, pandas |
| 30 | +- `[feature.minimum-scipy.dependencies]` - for scipy |
| 31 | +- `[feature.min-versions.dependencies]` - for all other pinned dependencies |
| 32 | +- `[package.run-dependencies]` - for packaging |
| 33 | + |
| 34 | +Example changes: |
| 35 | +```toml |
| 36 | +# [feature.minimal.dependencies] |
| 37 | +numpy = "2.0.*" # was "1.26.*" |
| 38 | + |
| 39 | +# [feature.minimum-scipy.dependencies] |
| 40 | +scipy = "1.15.*" # was "1.13.*" |
| 41 | + |
| 42 | +# [feature.min-versions.dependencies] |
| 43 | +zarr = "3.0.*" # was "2.18.*" |
| 44 | +dask-core = "2025.1.*" # was "2024.6.*" |
| 45 | +``` |
| 46 | + |
| 47 | +### 3. Update pyproject.toml |
| 48 | + |
| 49 | +Update the corresponding versions in `pyproject.toml` optional dependencies: |
| 50 | +- `dependencies` - numpy, packaging, pandas |
| 51 | +- `[project.optional-dependencies]` - accel, io, viz sections |
| 52 | + |
| 53 | +### 4. Verify Lock File |
| 54 | + |
| 55 | +```bash |
| 56 | +pixi lock |
| 57 | +``` |
| 58 | + |
| 59 | +This must pass. If it fails, there may be dependency conflicts to resolve. |
| 60 | + |
| 61 | +### 5. Verify Policy Compliance |
| 62 | + |
| 63 | +```bash |
| 64 | +pixi run policy-min-versions |
| 65 | +``` |
| 66 | + |
| 67 | +All packages should now show `=`. |
| 68 | + |
| 69 | +### 6. Clean Up Obsolete Test Decorators |
| 70 | + |
| 71 | +In `xarray/tests/__init__.py`, remove any `has_*` / `requires_*` decorators for versions that are now guaranteed by the new minimums. For example: |
| 72 | +- If numpy >= 2.0 is now required, remove `has_numpy_2` / `requires_numpy_2` |
| 73 | +- If dask >= 2025.1 is now required, remove `has_dask_ge_2024_*` / `has_dask_ge_2025_1_0` / `has_dask_expr` / `requires_dask_expr` |
| 74 | +- If zarr >= 3.0 is now required, remove `has_zarr_v3` / `requires_zarr_v3` |
| 75 | + |
| 76 | +Then search for all usages of the deleted decorators and fix those files: |
| 77 | + |
| 78 | +```bash |
| 79 | +# Search for usages of deleted decorators |
| 80 | +rg "has_scipy_ge_|has_dask_ge_|has_zarr_v3[^_]|has_pandas_ge_|has_numpy_2|has_dask_expr|requires_dask_expr" xarray/tests/ |
| 81 | +``` |
| 82 | + |
| 83 | +For each file found: |
| 84 | +- Remove imports of deleted decorators |
| 85 | +- Remove `@requires_*` decorators that are always true |
| 86 | +- Remove `if has_*:` conditionals (keep only the true branch) |
| 87 | +- Remove `if not has_*:` conditionals (delete the code block) |
| 88 | +- Delete tests marked with `@pytest.mark.skipif(has_*, ...)` (always skipped) |
| 89 | + |
| 90 | +### 7. Update whats-new.rst |
| 91 | + |
| 92 | +Add a table to `doc/whats-new.rst` under "Breaking Changes" documenting the version changes (in alphabetical order): |
| 93 | + |
| 94 | +```rst |
| 95 | +Breaking Changes |
| 96 | +~~~~~~~~~~~~~~~~ |
| 97 | +
|
| 98 | +- The minimum versions of some dependencies were changed: |
| 99 | +
|
| 100 | + ===================== ========= ======= |
| 101 | + Package Old New |
| 102 | + ===================== ========= ======= |
| 103 | + boto3 1.34 1.36 |
| 104 | + cartopy 0.23 0.24 |
| 105 | + dask 2024.6 2025.1 |
| 106 | + distributed 2024.6 2025.1 |
| 107 | + h5netcdf 1.4 1.5 |
| 108 | + iris 3.9 3.11 |
| 109 | + lxml 5.1 5.3 |
| 110 | + matplotlib 3.8 3.10 |
| 111 | + numpy 1.26 2.0 |
| 112 | + packaging 24.1 24.2 |
| 113 | + rasterio 1.3 1.4 |
| 114 | + scipy 1.13 1.15 |
| 115 | + toolz 0.12 1.0 |
| 116 | + zarr 2.18 3.0 |
| 117 | + ===================== ========= ======= |
| 118 | +``` |
| 119 | + |
| 120 | +## Common Issues |
| 121 | + |
| 122 | +### Lock file conflicts |
| 123 | +If `pixi lock` fails, check for incompatible version combinations. Some packages (like h5py/hdf5) are noted in comments as prone to conflicts. |
| 124 | + |
| 125 | +### Test failures after cleanup |
| 126 | +After removing version guards, some tests may fail if they relied on version-specific behavior. Update the test logic to use only the new minimum version's behavior. |
0 commit comments