Skip to content

Commit a2af7c5

Browse files
committed
bug in build counter
1 parent ef5b56c commit a2af7c5

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

dev/build_counter.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1+
"""
2+
Build counter script to increment build number on each build.
3+
4+
We update the __version__ module and the version in pyproject.toml to keep them in sync.
5+
"""
6+
17
import re
28
import subprocess
39
from pathlib import Path
410

511
from enum import Enum # isort: skip
612

713
class VersionStatus(Enum):
14+
"""
15+
Enumeration for version status.
16+
"""
817
ALPHA = "alpha"
918
BETA = "beta"
1019
RELEASE = "release"
1120

1221
__major_version__ = 0
1322
__minor_version__ = 26
14-
__revision_version__ = 0
23+
__revision_version__ = 1
1524
__author__ = "@joocer"
16-
__status__ = VersionStatus.RELEASE
25+
__status__ = VersionStatus.BETA
1726

1827
__build__ = None
19-
with open("opteryx/__version__.py", mode="r") as v:
28+
with open("opteryx/__version__.py", mode="r", encoding="utf-8") as v:
2029
vers = v.read()
2130
exec(vers) # nosec
2231

2332
if __build__:
2433
__build__ = int(__build__) + 1
25-
__version__ = f"{__major_version__}.{__minor_version__}.{__revision_version__}" + f"-{__status__.value}.{__build__}" if __status__ != VersionStatus.RELEASE else ""
34+
__version__ = f"{__major_version__}.{__minor_version__}.{__revision_version__}"
35+
if __status__ != VersionStatus.RELEASE:
36+
__version__ += f"-{__status__.value}.{__build__}"
2637

2738
VERSION_FILE_CONTENT = f"""# THIS FILE IS AUTOMATICALLY UPDATED DURING THE BUILD PROCESS
2839
# DO NOT EDIT THIS FILE DIRECTLY
@@ -48,14 +59,14 @@ class VersionStatus(Enum):
4859
print(__version__)
4960

5061
pyproject_path = Path("pyproject.toml")
51-
pyproject_contents = pyproject_path.read_text()
62+
pyproject_contents = pyproject_path.read_text(encoding="utf-8")
5263
pattern = re.compile(r'^(version\s*=\s*")[^"]*(")', re.MULTILINE)
5364
updated_contents, replacements = pattern.subn(f'version = "{__version__}"', pyproject_contents, count=1)
5465

5566
if replacements == 0:
5667
msg = "Unable to locate version field in pyproject.toml"
5768
raise ValueError(msg)
5869

59-
pyproject_path.write_text(updated_contents)
70+
pyproject_path.write_text(updated_contents, encoding="utf-8")
6071

6172
subprocess.run(["git", "add", "opteryx/__version__.py", "pyproject.toml"])

opteryx/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# THIS FILE IS AUTOMATICALLY UPDATED DURING THE BUILD PROCESS
22
# DO NOT EDIT THIS FILE DIRECTLY
33

4-
__build__ = 1725
4+
__build__ = 1726
55
__author__ = "@joocer"
6-
__version__ = ""
6+
__version__ = "0.26.1-beta.1726"
77

88
# Store the version here so:
99
# 1) we don't load dependencies by storing it in __init__.py

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "opteryx"
3-
version = "0.26.0"
3+
version = "0.26.1-beta.1726"
44
description = "Query your data, where it lives"
55
requires-python = '>=3.11'
66
readme = {file = "README.md", content-type = "text/markdown"}

0 commit comments

Comments
 (0)