|
1 | 1 | # Copyright (c) Jupyter Development Team. |
2 | 2 | # Distributed under the terms of the Modified BSD License. |
3 | | - |
| 3 | +import re |
4 | 4 | from collections import namedtuple |
5 | 5 |
|
6 | | -VersionInfo = namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]) |
| 6 | +# Use "hatch version xx.yy.zz" to handle version changes |
| 7 | +__version__ = "7.0.0a5" |
7 | 8 |
|
8 | | -# DO NOT EDIT THIS DIRECTLY! It is managed by bumpversion |
9 | | -version_info = VersionInfo(7, 0, 0, "alpha", 5) |
| 9 | +# PEP440 version parser |
| 10 | +_version_regex = re.compile( |
| 11 | + r""" |
| 12 | + (?P<major>\d+) |
| 13 | + \. |
| 14 | + (?P<minor>\d+) |
| 15 | + \. |
| 16 | + (?P<micro>\d+) |
| 17 | + (?P<releaselevel>((a|b|rc|\.dev)))? |
| 18 | + (?P<serial>\d+)? |
| 19 | + """, |
| 20 | + re.VERBOSE, |
| 21 | +) |
10 | 22 |
|
11 | | -_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""} |
| 23 | +_version_fields = _version_regex.match(__version__).groupdict() # type:ignore |
| 24 | + |
| 25 | +VersionInfo = namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]) |
12 | 26 |
|
13 | | -__version__ = "{}.{}.{}{}".format( |
14 | | - version_info.major, |
15 | | - version_info.minor, |
16 | | - version_info.micro, |
17 | | - ( |
18 | | - "" |
19 | | - if version_info.releaselevel == "final" |
20 | | - else _specifier_[version_info.releaselevel] + str(version_info.serial) |
21 | | - ), |
| 27 | +version_info = VersionInfo( |
| 28 | + *[ |
| 29 | + field |
| 30 | + for field in ( |
| 31 | + int(_version_fields["major"]), |
| 32 | + int(_version_fields["minor"]), |
| 33 | + int(_version_fields["micro"]), |
| 34 | + _version_fields["releaselevel"] or "", |
| 35 | + _version_fields["serial"] or "", |
| 36 | + ) |
| 37 | + ] |
22 | 38 | ) |
0 commit comments