Skip to content

Commit ea631f9

Browse files
keewismax-sixty
andauthored
update the minimum version policy (#4907)
* update the minimum version policy * adapt the minimum versions check script * improve the error message * update the length of the support windows for python and numpy * implement the new policy * Refine wording * add a entry to whats-new.rst * properly format the minimum versions table [skip-ci] * rewrite the error message for too new packages * reformat the policy [skip-ci] * remove the policy override for dask and distributed Co-authored-by: Maximilian Roos <[email protected]>
1 parent 5287c7b commit ea631f9

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

.github/workflows/ci-additional.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,6 @@ jobs:
184184

185185
- name: minimum versions policy
186186
run: |
187-
mamba install -y pyyaml conda
187+
mamba install -y pyyaml conda python-dateutil
188188
python ci/min_deps_check.py ci/requirements/py37-bare-minimum.yml
189189
python ci/min_deps_check.py ci/requirements/py37-min-all-deps.yml

ci/min_deps_check.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
"""
55
import itertools
66
import sys
7-
from datetime import datetime, timedelta
7+
from datetime import datetime
88
from typing import Dict, Iterator, Optional, Tuple
99

1010
import conda.api
1111
import yaml
12+
from dateutil.relativedelta import relativedelta
1213

1314
CHANNELS = ["conda-forge", "defaults"]
1415
IGNORE_DEPS = {
@@ -25,14 +26,9 @@
2526
"pytest-xdist",
2627
}
2728

28-
POLICY_MONTHS = {"python": 42, "numpy": 24, "setuptools": 42}
29+
POLICY_MONTHS = {"python": 24, "numpy": 18, "setuptools": 42}
2930
POLICY_MONTHS_DEFAULT = 12
3031
POLICY_OVERRIDE = {
31-
# dask < 2.9 has trouble with nan-reductions
32-
# TODO remove this special case and the matching note in installing.rst
33-
# after January 2021.
34-
"dask": (2, 9),
35-
"distributed": (2, 9),
3632
# setuptools-scm doesn't work with setuptools < 36.7 (Nov 2017).
3733
# The conda metadata is malformed for setuptools < 38.4 (Jan 2018)
3834
# (it's missing a timestamp which prevents this tool from working).
@@ -148,28 +144,32 @@ def process_pkg(
148144
return pkg, fmt_version(req_major, req_minor, req_patch), "-", "-", "-", "(!)"
149145

150146
policy_months = POLICY_MONTHS.get(pkg, POLICY_MONTHS_DEFAULT)
151-
policy_published = datetime.now() - timedelta(days=policy_months * 30)
152-
153-
policy_major = req_major
154-
policy_minor = req_minor
155-
policy_published_actual = req_published
156-
for (major, minor), published in reversed(sorted(versions.items())):
157-
if published < policy_published:
158-
break
159-
policy_major = major
160-
policy_minor = minor
161-
policy_published_actual = published
147+
policy_published = datetime.now() - relativedelta(months=policy_months)
148+
149+
filtered_versions = [
150+
version
151+
for version, published in versions.items()
152+
if published < policy_published
153+
]
154+
policy_major, policy_minor = max(filtered_versions, default=(req_major, req_minor))
162155

163156
try:
164157
policy_major, policy_minor = POLICY_OVERRIDE[pkg]
165158
except KeyError:
166159
pass
160+
policy_published_actual = versions[policy_major, policy_minor]
167161

168162
if (req_major, req_minor) < (policy_major, policy_minor):
169163
status = "<"
170164
elif (req_major, req_minor) > (policy_major, policy_minor):
171165
status = "> (!)"
172-
error("Package is too new: " + pkg)
166+
delta = relativedelta(datetime.now(), policy_published_actual).normalized()
167+
n_months = delta.years * 12 + delta.months
168+
error(
169+
f"Package is too new: {pkg}={req_major}.{req_minor} was "
170+
f"published on {versions[req_major, req_minor]:%Y-%m-%d} "
171+
f"which was {n_months} months ago (policy is {policy_months} months)"
172+
)
173173
else:
174174
status = "="
175175

doc/installing.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ Minimum dependency versions
9898
xarray adopts a rolling policy regarding the minimum supported version of its
9999
dependencies:
100100

101-
- **Python:** 42 months
101+
- **Python:** 24 months
102102
(`NEP-29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_)
103103
- **setuptools:** 42 months (but no older than 40.4)
104-
- **numpy:** 24 months
104+
- **numpy:** 18 months
105105
(`NEP-29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_)
106106
- **dask and dask.distributed:** 12 months (but no older than 2.9)
107107
- **sparse, pint** and other libraries that rely on
@@ -111,9 +111,9 @@ dependencies:
111111
numpy >=1.17.
112112
- **all other libraries:** 12 months
113113

114-
The above should be interpreted as *the minor version (X.Y) initially published no more
115-
than N months ago*. Patch versions (x.y.Z) are not pinned, and only the latest available
116-
at the moment of publishing the xarray release is guaranteed to work.
114+
This means the latest minor (X.Y) version from N months prior. Patch versions (x.y.Z)
115+
are not pinned, and only the latest available at the moment of publishing the xarray
116+
release is guaranteed to work.
117117

118118
You can see the actual minimum tested versions:
119119

doc/whats-new.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ Breaking changes
2424
~~~~~~~~~~~~~~~~
2525
- xarray no longer supports python 3.6
2626

27+
The minimum version policy was changed to also apply to projects with irregular
28+
releases.
29+
2730
The minimum versions of some other dependencies were changed:
31+
2832
============ ====== ====
2933
Package Old New
3034
============ ====== ====
3135
Python 3.6 3.7
3236
setuptools 38.4 40.4
3337
============ ====== ====
3438

35-
(:issue:`4688`, :pull:`4720`)
39+
(:issue:`4688`, :pull:`4720`, :pull:`4907`)
3640
By `Justus Magin <https://github.com/keewis>`_.
3741
- use ``pyproject.toml`` instead of the ``setup_requires`` option for
3842
``setuptools`` (:pull:`4897`).

0 commit comments

Comments
 (0)