|
13 | 13 | import re
|
14 | 14 | import subprocess
|
15 | 15 | import sys
|
| 16 | +from datetime import date |
16 | 17 | from pathlib import Path
|
17 | 18 |
|
18 | 19 | import requests
|
|
30 | 31 | os.path.join(tools.ROOT, f)
|
31 | 32 | for f in ["tooling", "requirements", ".github", "hypothesis-python/tox.ini"]
|
32 | 33 | )
|
| 34 | +TODAY = date.today().isoformat() |
33 | 35 |
|
34 | 36 |
|
35 | 37 | def task(if_changed=()):
|
@@ -321,6 +323,54 @@ def update_python_versions():
|
321 | 323 | build_sh.chmod(0o755)
|
322 | 324 |
|
323 | 325 |
|
| 326 | +DJANGO_VERSIONS = { |
| 327 | + "4.2": "4.2.16", |
| 328 | + "5.0": "5.0.9", |
| 329 | + "5.1": "5.1.3", |
| 330 | +} |
| 331 | + |
| 332 | + |
| 333 | +def update_django_versions(): |
| 334 | + # https://endoflife.date/django makes it easier to track these |
| 335 | + releases = requests.get("https://endoflife.date/api/django.json").json() |
| 336 | + versions = {r["cycle"]: r["latest"] for r in releases[::-1] if TODAY <= r["eol"]} |
| 337 | + |
| 338 | + if versions == DJANGO_VERSIONS: |
| 339 | + return |
| 340 | + |
| 341 | + # Write the new mapping back to this file |
| 342 | + thisfile = pathlib.Path(__file__) |
| 343 | + before = thisfile.read_text(encoding="utf-8") |
| 344 | + after = re.sub( |
| 345 | + r"DJANGO_VERSIONS = \{[^{}]+\}", |
| 346 | + "DJANGO_VERSIONS = " + repr(versions).replace("}", ",}"), |
| 347 | + before, |
| 348 | + ) |
| 349 | + thisfile.write_text(after, encoding="utf-8") |
| 350 | + pip_tool("shed", str(thisfile)) |
| 351 | + |
| 352 | + # Update the minimum version in setup.py |
| 353 | + setup_py = hp.BASE_DIR / "setup.py" |
| 354 | + content = re.sub( |
| 355 | + r"django>=\d+\.\d+", |
| 356 | + f"django>={min(versions, key=float)}", |
| 357 | + setup_py.read_text(encoding="utf-8"), |
| 358 | + ) |
| 359 | + setup_py.write_text(content, encoding="utf-8") |
| 360 | + |
| 361 | + # Automatically sync ci_version with the version in build.sh |
| 362 | + tox_ini = hp.BASE_DIR / "tox.ini" |
| 363 | + content = tox_ini.read_text(encoding="utf-8") |
| 364 | + print(versions) |
| 365 | + for short, full in versions.items(): |
| 366 | + content = re.sub( |
| 367 | + rf"(pip install django==){short}\.\d+", |
| 368 | + rf"\g<1>{full}", |
| 369 | + content, |
| 370 | + ) |
| 371 | + tox_ini.write_text(content, encoding="utf-8") |
| 372 | + |
| 373 | + |
324 | 374 | def update_pyodide_versions():
|
325 | 375 | vers_re = r"(\d+\.\d+\.\d+)"
|
326 | 376 | all_versions = re.findall(
|
@@ -391,6 +441,7 @@ def upgrade_requirements():
|
391 | 441 | f.write(f"RELEASE_TYPE: patch\n\n{msg}")
|
392 | 442 | update_python_versions()
|
393 | 443 | update_pyodide_versions()
|
| 444 | + update_django_versions() |
394 | 445 | subprocess.call(["git", "add", "."], cwd=tools.ROOT)
|
395 | 446 |
|
396 | 447 |
|
@@ -512,8 +563,8 @@ def standard_tox_task(name, py=ci_version):
|
512 | 563 | standard_tox_task("py39-pytest54", py="3.9")
|
513 | 564 | standard_tox_task("pytest62")
|
514 | 565 |
|
515 |
| -for n in [42, 50]: |
516 |
| - standard_tox_task(f"django{n}") |
| 566 | +for n in DJANGO_VERSIONS: |
| 567 | + standard_tox_task(f"django{n.replace('.', '')}") |
517 | 568 |
|
518 | 569 | for n in [13, 14, 15, 20, 21, 22]:
|
519 | 570 | standard_tox_task(f"pandas{n}")
|
|
0 commit comments