99"""
1010
1111import os
12+ import re
13+ import sys
1214import glob
1315from setuptools import setup
1416from setuptools import Extension
2628 'include_dirs' : get_numpy_include_dirs (),
2729}
2830
31+ # determine if we run with Python 3.
32+ PY3 = (sys .version_info [0 ] == 3 )
2933
3034# Figure out which boost library to use. This doesn't appear to consult
3135# LD_LIBRARY_PATH.
@@ -36,7 +40,7 @@ def get_boost_libraries():
3640 on the system. If required libraries are not found, an Exception will be
3741 thrown.
3842 """
39- baselib = "boost_python"
43+ baselib = "boost_python3" if PY3 else " boost_python"
4044 boostlibtags = ['' , '-mt' ] + ['' ]
4145 from ctypes .util import find_library
4246 for tag in boostlibtags :
@@ -52,7 +56,7 @@ def get_boost_libraries():
5256 if platform .system () == 'Darwin' :
5357 ldevname = 'DYLD_FALLBACK_LIBRARY_PATH'
5458 wmsg = ("Cannot detect name suffix for the %r library. "
55- "Consider setting %s." ) % (baselib , ldevname )
59+ "Consider setting %s." ) % (baselib , ldevname )
5660 warnings .warn (wmsg )
5761
5862 libs = [lib ]
@@ -76,9 +80,10 @@ def create_extensions():
7680versioncfgfile = os .path .join (MYDIR , 'src/pyobjcryst/version.cfg' )
7781gitarchivecfgfile = versioncfgfile .replace ('version.cfg' , 'gitarchive.cfg' )
7882
83+
7984def gitinfo ():
8085 from subprocess import Popen , PIPE
81- kw = dict (stdout = PIPE , cwd = MYDIR )
86+ kw = dict (stdout = PIPE , cwd = MYDIR , universal_newlines = True )
8287 proc = Popen (['git' , 'describe' , '--match=v[[:digit:]]*' ], ** kw )
8388 desc = proc .stdout .read ()
8489 proc = Popen (['git' , 'log' , '-1' , '--format=%H %at %ai' ], ** kw )
@@ -90,8 +95,10 @@ def gitinfo():
9095
9196
9297def getversioncfg ():
93- import re
94- from ConfigParser import RawConfigParser
98+ if PY3 :
99+ from configparser import RawConfigParser
100+ else :
101+ from ConfigParser import RawConfigParser
95102 vd0 = dict (version = FALLBACK_VERSION , commit = '' , date = '' , timestamp = 0 )
96103 # first fetch data from gitarchivecfgfile, ignore if it is unexpanded
97104 g = vd0 .copy ()
@@ -120,7 +127,8 @@ def getversioncfg():
120127 cp .set ('DEFAULT' , 'commit' , g ['commit' ])
121128 cp .set ('DEFAULT' , 'date' , g ['date' ])
122129 cp .set ('DEFAULT' , 'timestamp' , g ['timestamp' ])
123- cp .write (open (versioncfgfile , 'w' ))
130+ with open (versioncfgfile , 'w' ) as fp :
131+ cp .write (fp )
124132 return cp
125133
126134versiondata = getversioncfg ()
@@ -159,6 +167,9 @@ def getversioncfg():
159167 'Operating System :: Unix' ,
160168 'Programming Language :: C++' ,
161169 'Programming Language :: Python :: 2.7' ,
170+ 'Programming Language :: Python :: 3.4' ,
171+ 'Programming Language :: Python :: 3.5' ,
172+ 'Programming Language :: Python :: 3.6' ,
162173 'Topic :: Scientific/Engineering :: Chemistry' ,
163174 'Topic :: Scientific/Engineering :: Physics' ,
164175 'Topic :: Software Development :: Libraries' ,
0 commit comments