Skip to content

Commit 5b6b193

Browse files
authored
Merge pull request #312 from rethinkdb/gabor/fix-package-versioning
fix: do not depend on package to get the version
2 parents 45c6ea8 + 85410ce commit 5b6b193

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

rethinkdb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
# This file incorporates work covered by the following copyright:
1616
# Copyright 2010-2016 RethinkDB, all rights reserved.
1717

18-
VERSION = "2.4.0+source"
18+
VERSION = "2.4.11+source"

setup.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import setuptools
2323

24-
from rethinkdb.version import VERSION
25-
2624
try:
2725
import asyncio
2826

@@ -32,26 +30,22 @@
3230

3331

3432
RETHINKDB_VERSION_DESCRIBE = os.environ.get("RETHINKDB_VERSION_DESCRIBE")
35-
VERSION_RE = r"^v(?P<version>\d+\.\d+)\.(?P<patch>\d+)?(\.(?P<post>\w+))?$"
36-
37-
if RETHINKDB_VERSION_DESCRIBE:
38-
MATCH = re.match(VERSION_RE, RETHINKDB_VERSION_DESCRIBE)
33+
VERSION_RE = r"(?P<major>[0-9]+)\.(?P<minor>[0-9]+)\.(?P<patch>[0-9]+)(?P<pre_release>:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?P<meta>:\+[0-9A-Za-z-]+)?"
3934

40-
if MATCH:
41-
VERSION = MATCH.group("version")
35+
with open("rethinkdb/version.py", "r") as f:
36+
version_parts = re.search(VERSION_RE, f.read()).groups()
37+
VERSION = ".".join(filter(lambda x: x is not None, version_parts))
4238

43-
if MATCH.group("patch"):
44-
VERSION += "." + MATCH.group("patch")
4539

46-
if MATCH.group("post"):
47-
VERSION += "." + MATCH.group("post")
40+
if RETHINKDB_VERSION_DESCRIBE:
41+
version_parts = re.match(VERSION_RE, RETHINKDB_VERSION_DESCRIBE)
4842

49-
with open("rethinkdb/version.py", "w") as f:
50-
f.write('VERSION = {0}'.format(repr(VERSION)))
51-
else:
43+
if not version_parts:
5244
raise RuntimeError("{!r} does not match version format {!r}".format(
5345
RETHINKDB_VERSION_DESCRIBE, VERSION_RE))
5446

47+
VERSION = ".".join(filter(lambda x: x is not None, version_parts.groups()))
48+
5549

5650
setuptools.setup(
5751
name='rethinkdb',

0 commit comments

Comments
 (0)