Skip to content

Commit 37df2ba

Browse files
committed
fix: address config parser differences between py2 and 3
1 parent 22ca05c commit 37df2ba

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

nipype/pkg_info.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from future import standard_library
66
standard_library.install_aliases()
7-
from configparser import ConfigParser
7+
import configparser
88

99
import os
1010
import sys
@@ -47,7 +47,10 @@ def pkg_commit_hash(pkg_path):
4747
pth = os.path.join(pkg_path, COMMIT_INFO_FNAME)
4848
if not os.path.isfile(pth):
4949
raise IOError('Missing commit info file %s' % pth)
50-
cfg_parser = ConfigParser()
50+
if PY3:
51+
cfg_parser = configparser.RawConfigParser()
52+
else:
53+
cfg_parser = configparser.ConfigParser()
5154
cfg_parser.read(pth)
5255
archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash')
5356
if not archive_subst.startswith('$Format'): # it has been substituted

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class BuildWithCommitInfoCommand(build_py):
6060
package for an example.
6161
"""
6262
def run(self):
63-
from configparser import ConfigParser
6463
import subprocess
64+
import configparser
6565

6666
build_py.run(self)
6767
proc = subprocess.Popen('git rev-parse --short HEAD',
@@ -74,7 +74,10 @@ def run(self):
7474
repo_commit = repo_commit.decode()
7575

7676
# We write the installation commit even if it's empty
77-
cfg_parser = ConfigParser()
77+
if PY3:
78+
cfg_parser = configparser.RawConfigParser()
79+
else:
80+
cfg_parser = configparser.ConfigParser()
7881
cfg_parser.read(pjoin('nipype', 'COMMIT_INFO.txt'))
7982
cfg_parser.set('commit hash', 'install_hash', repo_commit.strip())
8083
out_pth = pjoin(self.build_lib, 'nipype', 'COMMIT_INFO.txt')

0 commit comments

Comments
 (0)