From a5f19aa1a139203977be726879d2f8cb336ac0ec Mon Sep 17 00:00:00 2001 From: Geoff Pleiss Date: Thu, 11 Aug 2022 17:21:16 +0000 Subject: [PATCH] Fix version finding in docs/source/conf. --- docs/source/conf.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b9880ae7..ceb649ae 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,39 +15,26 @@ # sys.path.insert(0, os.path.abspath('.')) import os -import io -import re import sys import warnings import sphinx_rtd_theme # noqa from typing import ForwardRef -def read(*names, **kwargs): - with io.open( - os.path.join(os.path.dirname(__file__), "..", "..", *names), encoding=kwargs.get("encoding", "utf8") - ) as fp: - return fp.read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - - sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..", ".."))) # -- Project information ----------------------------------------------------- project = "linear_operator" -copyright = "2020, Cornellius GP" +copyright = "2022, Cornellius GP" author = "Cornellius GP" # The full version, including alpha/beta/rc tags -version = find_version("linear_operator", "__init__.py") +try: + from linear_operator.version import version +except Exception: # pragma: no cover + version = "Unknown" # pragma: no cover + release = version