Skip to content

Commit 230a178

Browse files
committed
PY2: ConfigParser for Sphinx build
1 parent 80b6174 commit 230a178

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doc/source/conf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121

2222
import sys
2323
import os
24-
from configparser import ConfigParser
24+
try:
25+
from configparser import ConfigParser
26+
except ImportError:
27+
from ConfigParser import ConfigParser # PY2
2528

2629
# Check for external Sphinx extensions we depend on
2730
try:
@@ -59,6 +62,10 @@
5962
# Load metadata from setup.cfg
6063
config = ConfigParser()
6164
config.read(os.path.join('..', '..', 'setup.cfg'))
65+
try:
66+
metadata = config['metadata']
67+
except AttributeError:
68+
metadata = dict(config.items('metadata')) # PY2
6269

6370
# Add any Sphinx extension module names here, as strings. They can be
6471
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
@@ -92,7 +99,7 @@
9299

93100
# General information about the project.
94101
project = u'NiBabel'
95-
copyright = u'2006-2019, %(maintainer)s <%(author_email)s>' % config['metadata']
102+
copyright = u'2006-2019, %(maintainer)s <%(author_email)s>' % metadata
96103

97104
# The version info for the project you're documenting, acts as replacement for
98105
# |version| and |release|, also used in various other places throughout the

0 commit comments

Comments
 (0)