Skip to content

Commit 01feb18

Browse files
authored
Merge pull request #1890 from satra/fix/configparser
fix: address config parser differences between py2 and 3
2 parents addda24 + 3967419 commit 01feb18

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

nipype/pkg_info.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import print_function, division, unicode_literals, absolute_import
3-
from builtins import open
43

54
from future import standard_library
65
standard_library.install_aliases()
7-
from configparser import ConfigParser
6+
import configparser
87

98
import os
109
import sys
1110
import subprocess
1211

12+
from .info import VERSION
13+
1314
COMMIT_INFO_FNAME = 'COMMIT_INFO.txt'
1415
PY3 = sys.version_info[0] >= 3
1516

@@ -47,7 +48,10 @@ def pkg_commit_hash(pkg_path):
4748
pth = os.path.join(pkg_path, COMMIT_INFO_FNAME)
4849
if not os.path.isfile(pth):
4950
raise IOError('Missing commit info file %s' % pth)
50-
cfg_parser = ConfigParser()
51+
if PY3:
52+
cfg_parser = configparser.RawConfigParser()
53+
else:
54+
cfg_parser = configparser.ConfigParser()
5155
cfg_parser.read(pth)
5256
archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash')
5357
if not archive_subst.startswith('$Format'): # it has been substituted
@@ -91,6 +95,7 @@ def get_pkg_info(pkg_path):
9195
pkg_path=pkg_path,
9296
commit_source=src,
9397
commit_hash=hsh,
98+
nipype_version=VERSION,
9499
sys_version=sys.version,
95100
sys_executable=sys.executable,
96101
sys_platform=sys.platform,

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)