|
4 | 4 | """
|
5 | 5 | import itertools
|
6 | 6 | import sys
|
7 |
| -from datetime import datetime, timedelta |
| 7 | +from datetime import datetime |
8 | 8 | from typing import Dict, Iterator, Optional, Tuple
|
9 | 9 |
|
10 | 10 | import conda.api
|
11 | 11 | import yaml
|
| 12 | +from dateutil.relativedelta import relativedelta |
12 | 13 |
|
13 | 14 | CHANNELS = ["conda-forge", "defaults"]
|
14 | 15 | IGNORE_DEPS = {
|
|
25 | 26 | "pytest-xdist",
|
26 | 27 | }
|
27 | 28 |
|
28 |
| -POLICY_MONTHS = {"python": 42, "numpy": 24, "setuptools": 42} |
| 29 | +POLICY_MONTHS = {"python": 24, "numpy": 18, "setuptools": 42} |
29 | 30 | POLICY_MONTHS_DEFAULT = 12
|
30 | 31 | 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), |
36 | 32 | # setuptools-scm doesn't work with setuptools < 36.7 (Nov 2017).
|
37 | 33 | # The conda metadata is malformed for setuptools < 38.4 (Jan 2018)
|
38 | 34 | # (it's missing a timestamp which prevents this tool from working).
|
@@ -148,28 +144,32 @@ def process_pkg(
|
148 | 144 | return pkg, fmt_version(req_major, req_minor, req_patch), "-", "-", "-", "(!)"
|
149 | 145 |
|
150 | 146 | 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)) |
162 | 155 |
|
163 | 156 | try:
|
164 | 157 | policy_major, policy_minor = POLICY_OVERRIDE[pkg]
|
165 | 158 | except KeyError:
|
166 | 159 | pass
|
| 160 | + policy_published_actual = versions[policy_major, policy_minor] |
167 | 161 |
|
168 | 162 | if (req_major, req_minor) < (policy_major, policy_minor):
|
169 | 163 | status = "<"
|
170 | 164 | elif (req_major, req_minor) > (policy_major, policy_minor):
|
171 | 165 | 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 | + ) |
173 | 173 | else:
|
174 | 174 | status = "="
|
175 | 175 |
|
|
0 commit comments