Skip to content

Commit f976f58

Browse files
committed
Make setup.py compatible with both Python 2 and 3.
1 parent 587d6a9 commit f976f58

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"""
77

88
import os
9+
import re
10+
import sys
911
from setuptools import setup, find_packages
1012

1113
# Use this version when git data are not available, like in git zip archive.
@@ -21,7 +23,7 @@
2123

2224
def gitinfo():
2325
from subprocess import Popen, PIPE
24-
kw = dict(stdout=PIPE, cwd=MYDIR)
26+
kw = dict(stdout=PIPE, cwd=MYDIR, universal_newlines=True)
2527
proc = Popen(['git', 'describe', '--match=v[[:digit:]]*'], **kw)
2628
desc = proc.stdout.read()
2729
proc = Popen(['git', 'log', '-1', '--format=%H %at %ai'], **kw)
@@ -33,8 +35,10 @@ def gitinfo():
3335

3436

3537
def getversioncfg():
36-
import re
37-
from ConfigParser import RawConfigParser
38+
if sys.version_info[0] >= 3:
39+
from configparser import RawConfigParser
40+
else:
41+
from ConfigParser import RawConfigParser
3842
vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0)
3943
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
4044
g = vd0.copy()

0 commit comments

Comments
 (0)