diff --git a/.gitignore b/.gitignore index 23e954719..aed030c40 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *.swp build/ demo/README.rst -docs/build \ No newline at end of file +docs/build +docs/_build.py diff --git a/docs/conf.py b/docs/conf.py index 2cd93940b..d6b49115f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -49,16 +49,8 @@ # built documents. # # The full version, including alpha/beta/rc tags. -_path = os.path.abspath(f'{__file__}/../../src/__init__.py') -with open(_path) as f: - for line in f: - match = re.search('pymupdf_version = "([0-9][.][0-9]+[.][0-9]+(rc[0-9]+)?)"', line) - if match: - release = match.group(1) - print(f'{__file__}: setting version from {_path}: {release}') - break - else: - raise Exception(f'Failed to find `VersionBind = ...` in {_path}') +from _build import pymupdf_version as release # noqa F401 +print(f'{__file__}: setting version from _build.py: {release}') # The short X.Y version version = release diff --git a/setup.py b/setup.py index 3072a795c..69d62f3c6 100755 --- a/setup.py +++ b/setup.py @@ -743,6 +743,8 @@ def add(flavour, from_, to_): text += f'pymupdf_git_diff = {diff!r}\n' text += f'pymupdf_git_branch = {branch!r}\n' add('p', text.encode(), f'{to_dir}/_build.py') + with open('docs/_build.py', 'w') as f: + f.write(text) # Add single README file. if 'p' in PYMUPDF_SETUP_FLAVOUR: