Skip to content

Commit

Permalink
fix undefined symbols error. This commit should fix build for python3…
Browse files Browse the repository at this point in the history
… and keep backwards compatibility for python2
  • Loading branch information
mhuen committed Apr 26, 2020
1 parent 2c1e879 commit 156c233
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ def get_boost_include_list():
return include_dirs


def get_i3_lib_list():
"""Helper function to get directories for libraries
"""
import os
i3_lib_list = []
if 'SROOT' in os.environ:
i3_lib_list.append(os.path.join(os.environ['SROOT'], 'lib/'))
i3_lib_list.append(os.path.join(os.environ['I3_BUILD'], 'lib/'))
return i3_lib_list


def get_boost_libraries():
"""Helper function to get a list of libraries to link against
"""
import sys
if sys.version_info.major >= 3:
# python 3 libraries
libraries = ['boost_python36', 'boost_numpy36', 'phys-services']
else:
# python 2 libraries
libraries = ['boost_python', 'phys-services']
return libraries


ext_modules = [
Extension(
'ic3_data.ext_pybind11',
Expand All @@ -90,6 +114,8 @@ def get_boost_include_list():
Extension(
'ic3_data.ext_boost',
['ic3_data_ext/ext_boost.cpp'],
libraries=get_boost_libraries(),
library_dirs=get_i3_lib_list(),
include_dirs=get_boost_include_list(),
language='c++'
),
Expand Down Expand Up @@ -139,12 +165,14 @@ def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(
'-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
opts.append(
'/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
Expand Down

0 comments on commit 156c233

Please sign in to comment.