diff --git a/docs/conf.py b/docs/conf.py index 877827bba24..c75f5ed1801 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,19 +25,21 @@ # -- General configuration ------------------------------------------------ import datetime import os +import sys +from pathlib import Path -# Get configuration information from setup.cfg -from configparser import ConfigParser +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib # Sphinx gallery from sphinx_gallery.sorting import ExplicitOrder, FileNameSortKey import ctapipe -setup_cfg = ConfigParser() -setup_cfg.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")]) -setup_metadata = dict(setup_cfg.items("metadata")) -setup_options = dict(setup_cfg.items("options")) +pyproject_path = Path(__file__).parent.parent / "pyproject.toml" +pyproject = tomllib.loads(pyproject_path.read_text()) # Add any Sphinx extension module names here, as strings. They can be @@ -201,12 +203,12 @@ def setup(app): # General information about the project. -project = setup_metadata["name"] -author = setup_metadata["author"] +project = pyproject["project"]["name"] +author = pyproject["project"]["authors"][0]["name"] copyright = "{}. Last updated {}".format( - setup_metadata["author"], datetime.datetime.now().strftime("%d %b %Y %H:%M") + author, datetime.datetime.now().strftime("%d %b %Y %H:%M") ) -python_requires = setup_options["python_requires"] +python_requires = pyproject["project"]["requires-python"] # make some variables available to each page rst_epilog = f""" diff --git a/pyproject.toml b/pyproject.toml index 6062eaf0939..617535e0b5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ docs = [ "ipython", "ffmpeg-python", "pypandoc", + "tomli; python_version < '3.11'", ] dev = [