Skip to content

Commit 4737b81

Browse files
committed
DEV: link with boost_python3 when using Python 3.
Fix build on homebrew with python3. Avoid cross linking with boost_python for Python 2.
1 parent 5f2f129 commit 4737b81

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Diff for: SConstruct

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ env.MergeFlags([os.environ.get(n, '') for n in flagnames])
9393
good_python_flags = lambda n : (
9494
not isinstance(n, basestring) or
9595
not re.match(r'(-g|-Wstrict-prototypes|-O\d)$', n))
96-
pyver = pyoutput('import sys; print("%i.%i" % sys.version_info[:2])')
97-
pythonconfig = 'python' + pyver + '-config'
96+
pyversion = pyoutput('import sys; print("%i.%i" % sys.version_info[:2])')
97+
pythonconfig = 'python' + pyversion + '-config'
9898
env.ParseConfig(pythonconfig + " --cflags")
9999
env.Replace(CCFLAGS=filter(good_python_flags, env['CCFLAGS']))
100100
env.Replace(CPPDEFINES='')
@@ -145,7 +145,7 @@ if env['profile']:
145145

146146
builddir = env.Dir('build/%s-%s' % (env['build'], platform.machine()))
147147

148-
Export('env', 'pyconfigvar', 'pyoutput')
148+
Export('env', 'pyconfigvar', 'pyoutput', 'pyversion')
149149

150150
if os.path.isfile('sconscript.local'):
151151
env.SConscript('sconscript.local')

Diff for: setup.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
'include_dirs' : get_numpy_include_dirs(),
2929
}
3030

31+
# determine if we run with Python 3.
32+
PY3 = (sys.version_info[0] == 3)
3133

3234
# Figure out which boost library to use. This doesn't appear to consult
3335
# LD_LIBRARY_PATH.
@@ -38,7 +40,7 @@ def get_boost_libraries():
3840
on the system. If required libraries are not found, an Exception will be
3941
thrown.
4042
"""
41-
baselib = "boost_python"
43+
baselib = "boost_python3" if PY3 else "boost_python"
4244
boostlibtags = ['', '-mt'] + ['']
4345
from ctypes.util import find_library
4446
for tag in boostlibtags:
@@ -54,7 +56,7 @@ def get_boost_libraries():
5456
if platform.system() == 'Darwin':
5557
ldevname = 'DYLD_FALLBACK_LIBRARY_PATH'
5658
wmsg = ("Cannot detect name suffix for the %r library. "
57-
"Consider setting %s.") % (baselib, ldevname)
59+
"Consider setting %s.") % (baselib, ldevname)
5860
warnings.warn(wmsg)
5961

6062
libs = [lib]
@@ -93,7 +95,7 @@ def gitinfo():
9395

9496

9597
def getversioncfg():
96-
if sys.version_info[0] >= 3:
98+
if PY3:
9799
from configparser import RawConfigParser
98100
else:
99101
from ConfigParser import RawConfigParser

Diff for: src/extensions/SConscript.configure

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Import('env', 'pyconfigvar')
1+
Import('env', 'pyconfigvar', 'pyversion')
22

33
# Helper functions -----------------------------------------------------------
44

@@ -11,6 +11,9 @@ def configure_boost_library(libname):
1111
1212
Note: CheckLib function automatically adds library to the environment.
1313
'''
14+
# adjust libname for boost_python
15+
if libname == 'boost_python' and pyversion[0] == '3':
16+
libname = 'boost_python3'
1417
# using global conf defined below
1518
for t in boostlibtags:
1619
libnamefull = libname + t

0 commit comments

Comments
 (0)