Skip to content

Commit c45bb12

Browse files
author
Ben Cipollini
committed
Make setup.py py3x compatible.
1 parent f1d126a commit c45bb12

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@
3737
''' Distutils / setuptools helpers from nibabel.nisext'''
3838

3939
import os
40-
from os.path import join as pjoin, split as psplit, splitext
40+
from os.path import join as pjoin
4141
import sys
42-
from configparser import ConfigParser
42+
PY3 = sys.version_info[0] >= 3
43+
if PY3:
44+
string_types = str,
45+
else:
46+
string_types = basestring,
47+
try:
48+
from ConfigParser import ConfigParser
49+
except ImportError:
50+
from configparser import ConfigParser
4351

4452
from distutils.version import LooseVersion
4553
from distutils.command.build_py import build_py
@@ -108,7 +116,7 @@ def _add_append_key(in_dict, key, value):
108116
# Append value to in_dict[key] list
109117
if key not in in_dict:
110118
in_dict[key] = []
111-
elif isinstance(in_dict[key], str):
119+
elif isinstance(in_dict[key], string_types):
112120
in_dict[key] = [in_dict[key]]
113121
in_dict[key].append(value)
114122

@@ -205,7 +213,7 @@ def version_getter(pkg_name):
205213
+ msgs['opt suffix'])
206214
return
207215
# setuptools mode
208-
if optional_tf and not isinstance(optional, str):
216+
if optional_tf and not isinstance(optional, string_types):
209217
raise RuntimeError('Not-False optional arg should be string')
210218
dependency = pkg_name
211219
if version:
@@ -286,7 +294,7 @@ def main(**extra_args):
286294
version=VERSION,
287295
install_requires=REQUIRES,
288296
provides=PROVIDES,
289-
packages = [ 'nipype',
297+
packages = [ 'nipype',
290298
'nipype.algorithms',
291299
'nipype.algorithms.tests',
292300
'nipype.caching',

0 commit comments

Comments
 (0)