diff --git a/arraycontext/version.py b/arraycontext/version.py index 30c96291467fd040193baf92ab98b9c398c895c8..a1da82c1f4244fe0daf3e99d52fe7650e6c5a56e 100644 --- a/arraycontext/version.py +++ b/arraycontext/version.py @@ -1,2 +1,15 @@ -VERSION = (2021, 1) -VERSION_TEXT = ".".join(str(i) for i in VERSION) +from importlib import metadata +from typing import Tuple + + +def _parse_version(version: str) -> Tuple[Tuple[int, ...], str]: + import re + + m = re.match("^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT) + assert m is not None + + return tuple([int(nr) for nr in m.group(1).split(".")]), m.group(2) + + +VERSION_TEXT = metadata.version("arraycontext") +VERSION, VERSION_STATUS = _parse_version(VERSION_TEXT) diff --git a/doc/conf.py b/doc/conf.py index 13c8dd20b700094a0e6023a37282a2871b7c8818..0ba49301494de11c1ce5bb59832676034808eaf5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,3 +1,4 @@ +from importlib import metadata from urllib.request import urlopen @@ -8,12 +9,8 @@ with urlopen(_conf_url) as _inf: copyright = "2021, University of Illinois Board of Trustees" author = "Arraycontext Contributors" - -ver_dic = {} -exec(compile(open("../arraycontext/version.py").read(), "../arraycontext/version.py", - "exec"), ver_dic) -version = ".".join(str(x) for x in ver_dic["VERSION"]) -release = ver_dic["VERSION_TEXT"] +release = metadata.version("arraycontext") +version = ".".join(release.split(".")[:2]) intersphinx_mapping = { "jax": ("https://jax.readthedocs.io/en/latest/", None),