Skip to content

Commit 2191873

Browse files
authored
Merge pull request #1662 from minrk/tbump
adopt tbump for versions
2 parents 5b168a2 + 96a8722 commit 2191873

File tree

4 files changed

+44
-151
lines changed

4 files changed

+44
-151
lines changed

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,34 @@ requires = [
1717
"cffi; implementation_name == 'pypy'",
1818
]
1919
build-backend = "setuptools.build_meta"
20+
21+
[tool.tbump]
22+
# Uncomment this if your project is hosted on GitHub:
23+
github_url = "https://github.com/zeromq/pyzmq"
24+
25+
[tool.tbump.version]
26+
current = "23.0.0.dev"
27+
regex = '''
28+
(?P<major>\d+)
29+
\.
30+
(?P<minor>\d+)
31+
\.
32+
(?P<patch>\d+)
33+
(?P<pre>((a|b|rc|)\d+)|.dev\d*|)
34+
'''
35+
36+
[tool.tbump.git]
37+
message_template = "Bump to {new_version}"
38+
tag_template = "v{new_version}"
39+
40+
# For each file to patch, add a [[tool.tbump.file]] config
41+
# section containing the path of the file, relative to the
42+
# pyproject.toml location.
43+
44+
[[tool.tbump.file]]
45+
src = "setup.py"
46+
search = 'version="{current_version}"'
47+
48+
[[tool.tbump.file]]
49+
src = "zmq/sugar/version.py"
50+
search = '__version__: str = "{current_version}"'

setup.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,22 +1302,6 @@ def finalize_options(self):
13021302
}
13031303

13041304

1305-
def extract_version():
1306-
"""extract pyzmq version from sugar/version.py, so it's not multiply defined"""
1307-
with open(pjoin('zmq', 'sugar', 'version.py')) as f:
1308-
while True:
1309-
line = f.readline()
1310-
if line.startswith('VERSION'):
1311-
lines = ["from typing import *\n"]
1312-
while line and not line.startswith('def'):
1313-
lines.append(line)
1314-
line = f.readline()
1315-
break
1316-
ns = {}
1317-
exec(''.join(lines), ns)
1318-
return ns['__version__']
1319-
1320-
13211305
def find_packages():
13221306
"""adapted from IPython's setupbase.find_packages()"""
13231307
packages = []
@@ -1339,7 +1323,7 @@ def find_packages():
13391323

13401324
setup_args = dict(
13411325
name="pyzmq",
1342-
version=extract_version(),
1326+
version="23.0.0.dev",
13431327
packages=find_packages(),
13441328
ext_modules=extensions,
13451329
cffi_modules=cffi_modules,

tools/tasks.py

Lines changed: 0 additions & 126 deletions
This file was deleted.

zmq/sugar/version.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
# Copyright (C) PyZMQ Developers
44
# Distributed under the terms of the Modified BSD License.
55

6-
from typing import Tuple, Union
6+
import re
7+
from typing import Match, Tuple, Union, cast
78

89
from zmq.backend import zmq_version_info
910

10-
VERSION_MAJOR = 22
11-
VERSION_MINOR = 3
12-
VERSION_PATCH = 0
13-
VERSION_EXTRA = ""
14-
__version__: str = '%i.%i.%i' % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
11+
__version__: str = "23.0.0.dev"
12+
_version_pat = re.compile(r"(\d+)\.(\d+)\.(\d+)(.*)")
13+
_match = cast(Match, _version_pat.match(__version__))
14+
_version_groups = _match.groups()
15+
16+
VERSION_MAJOR = int(_version_groups[0])
17+
VERSION_MINOR = int(_version_groups[1])
18+
VERSION_PATCH = int(_version_groups[2])
19+
VERSION_EXTRA = _version_groups[3].lstrip(".")
1520

1621
version_info: Union[Tuple[int, int, int], Tuple[int, int, int, float]] = (
1722
VERSION_MAJOR,
@@ -20,7 +25,6 @@
2025
)
2126

2227
if VERSION_EXTRA:
23-
__version__ = f"{__version__}.{VERSION_EXTRA}"
2428
version_info = (
2529
VERSION_MAJOR,
2630
VERSION_MINOR,
@@ -34,7 +38,7 @@
3438
def pyzmq_version() -> str:
3539
"""return the version of pyzmq as a string"""
3640
if __revision__:
37-
return '@'.join([__version__, __revision__[:6]])
41+
return '+'.join([__version__, __revision__[:6]])
3842
else:
3943
return __version__
4044

0 commit comments

Comments
 (0)