Skip to content

Commit c138e10

Browse files
committed
py/makeversionhdr: Fall back to py/mpconfig.h instead of docs/conf.py.
Commit 64af916 removed the version string from docs/conf.py. py/mpconfig.h is a better place to get the version from, so use that (when there is no git repository). Signed-off-by: Damien George <[email protected]>
1 parent 11910e2 commit c138e10

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

py/makeversionhdr.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,27 @@ def get_version_info_from_git():
6262
return git_tag, git_hash
6363

6464

65-
def get_version_info_from_docs_conf():
66-
with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "docs", "conf.py")) as f:
65+
def get_version_info_from_mpconfig():
66+
with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "py", "mpconfig.h")) as f:
6767
for line in f:
68-
if line.startswith("version = release = '"):
69-
ver = line.strip().split(" = ")[2].strip("'")
70-
git_tag = "v" + ver
68+
if line.startswith("#define MICROPY_VERSION_MAJOR "):
69+
ver_major = int(line.strip().split()[2])
70+
elif line.startswith("#define MICROPY_VERSION_MINOR "):
71+
ver_minor = int(line.strip().split()[2])
72+
elif line.startswith("#define MICROPY_VERSION_MICRO "):
73+
ver_micro = int(line.strip().split()[2])
74+
git_tag = "v%d.%d" % (ver_major, ver_minor)
75+
if ver_micro != 0:
76+
git_tag += ".%d" % (ver_micro,)
7177
return git_tag, "<no hash>"
7278
return None
7379

7480

7581
def make_version_header(filename):
76-
# Get version info using git, with fallback to docs/conf.py
82+
# Get version info using git, with fallback to py/mpconfig.h
7783
info = get_version_info_from_git()
7884
if info is None:
79-
info = get_version_info_from_docs_conf()
85+
info = get_version_info_from_mpconfig()
8086

8187
git_tag, git_hash = info
8288

0 commit comments

Comments
 (0)