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