diff --git a/doc/conf.py b/doc/conf.py index 5965f74..f16b0da 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,23 +18,33 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. -author = 'CFEL Controlled Molecule Imaging group' -copyright = '2018–2020 CFEL Controlled Molecule Imaging group ' -name = 'pymepix' -project = name -version = '1.1.dev0' -release = version - import os import sys +import pathlib + +# accessing the setup.py file to get current information about the project +name, project, version, release, author, copyright = [None] * 6 +desired = ['copyright', 'project', 'name', 'version', 'release', 'author'] + +# importlib.util.spec_from_file_location didn't work as I hoped it would +# first get the path of the setup.py file +current_path = pathlib.Path(__file__).parent.absolute() +setup_path = current_path.parent.joinpath("setup.py") + +# access setup.py as text file to find the necessary lines, then execute those +with open(setup_path, 'r') as f: + for i, line in enumerate(f): + line = line.strip() + line_list = line.split() + if len(line_list) > 0 and line_list[0] in desired: + exec(line) + desired.remove(line_list[0]) sys.path.insert(0, os.path.abspath('../../lib/')) print(sys.path) # -- General configuration ------------------------------------------------ -author = 'CFEL Controlled Molecule Imaging group' - # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0'