| 1 |
"""Ensure that current version is not in conflict with published releases.""" |
| 2 |
|
| 3 |
from packaging.version import Version |
| 4 |
import subprocess as subp |
| 5 |
from pathlib import PurePath |
| 6 |
import urllib.request |
| 7 |
import json |
| 8 |
import warnings |
| 9 |
import sys |
| 10 |
|
| 11 |
|
| 12 |
project_dir = PurePath(__file__).parent.parent |
| 13 |
changelog_fn = project_dir / "doc/changelog.rst" |
| 14 |
version_fn = project_dir / "version.py" |
| 15 |
|
| 16 |
version = subp.check_output([sys.executable, version_fn]).strip().decode() |
| 17 |
|
| 18 |
with warnings.catch_warnings(record=True) as record: |
| 19 |
iminuit_version = Version(version) |
| 20 |
if record: |
| 21 |
raise ValueError(record[0].message) |
| 22 |
|
| 23 |
print("iminuit version:", iminuit_version) |
| 24 |
|
| 25 |
# make sure that changelog was updated |
| 26 |
with open(changelog_fn) as f: |
| 27 |
assert iminuit_version.base_version in f.read(), "changelog entry missing" |
| 28 |
|
| 29 |
# make sure that version is not already tagged |
| 30 |
tags = subp.check_output(["git", "tag"]).decode().strip().split("\n") |
| 31 |
assert f"v{iminuit_version}" not in tags, "tag exists" |
| 32 |
|
| 33 |
# make sure that version itself was updated |
| 34 |
with urllib.request.urlopen("https://pypi.org/pypi/iminuit/json") as r: |
| 35 |
pypi_versions = [Version(v) for v in json.loads(r.read())["releases"]] |
| 36 |
|
| 37 |
pypi_versions.sort() |
| 38 |
print("PyPI version:", pypi_versions[-1]) |
| 39 |
|
| 40 |
assert iminuit_version not in pypi_versions, "pypi version exists" |