Skip to content

Commit

Permalink
Merge pull request #1484 from boegel/BoostPython
Browse files Browse the repository at this point in the history
add support for only building Python bindings (+ code cleanup) in Boost easyblock
  • Loading branch information
damianam committed Aug 24, 2018
2 parents e2dd3d2 + 6e03b03 commit cf5eeab
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions easybuild/easyblocks/b/boost.py
Expand Up @@ -49,7 +49,7 @@
from easybuild.framework.easyblock import EasyBlock
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import write_file
from easybuild.tools.filetools import copy, mkdir, write_file
from easybuild.tools.modules import get_software_root, get_software_version
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import UNKNOWN, get_glibc_version, get_shared_lib_ext
Expand All @@ -72,6 +72,7 @@ def extra_options():
'boost_multi_thread': [False, "Build boost with multi-thread option", CUSTOM],
'toolset': [None, "Toolset to use for Boost configuration ('--with-toolset for bootstrap.sh')", CUSTOM],
'mpi_launcher': [None, "Launcher to use when running MPI regression tests", CUSTOM],
'only_python_bindings': [False, "Only install Boost.Python library providing Python bindings", CUSTOM],
'use_glibcxx11_abi': [None, "Use the GLIBCXX11 ABI", CUSTOM],
}
return EasyBlock.extra_options(extra_vars)
Expand Down Expand Up @@ -103,12 +104,8 @@ def configure_step(self):
raise EasyBuildError("When enabling building boost_mpi, also enable the 'usempi' toolchain option.")

# create build directory (Boost doesn't like being built in source dir)
try:
self.objdir = os.path.join(self.builddir, 'obj')
os.mkdir(self.objdir)
self.log.debug("Succesfully created directory %s" % self.objdir)
except OSError, err:
raise EasyBuildError("Failed to create directory %s: %s", self.objdir, err)
self.objdir = os.path.join(self.builddir, 'obj')
mkdir(self.objdir)

# generate config depending on compiler used
toolset = self.cfg['toolset']
Expand Down Expand Up @@ -201,6 +198,11 @@ def build_step(self):
if self.cfg['parallel']:
paracmd = "-j %s" % self.cfg['parallel']

if self.cfg['only_python_bindings']:
# magic incantation to only install Boost Python bindings is... --with-python
# see http://boostorg.github.io/python/doc/html/building/installing_boost_python_on_your_.html
bjamoptions += " --with-python"

if self.cfg['boost_mpi']:
self.log.info("Building boost_mpi library")
self.build_boost_variant(bjamoptions + " --user-config=user-config.jam --with-mpi", paracmd)
Expand All @@ -225,29 +227,22 @@ def install_step(self):
"""Install Boost by copying file to install dir."""

self.log.info("Copying %s to installation dir %s" % (self.objdir, self.installdir))

try:
for f in os.listdir(self.objdir):
src = os.path.join(self.objdir, f)
dst = os.path.join(self.installdir, f)
if os.path.isdir(src):
shutil.copytree(src, dst)
else:
shutil.copy2(src, dst)
except OSError, err:
raise EasyBuildError("Copying %s to installation dir %s failed: %s", self.objdir, self.installdir, err)
copy(glob.glob(os.path.join(self.objdir, '*')), self.installdir)

def sanity_check_step(self):
"""Custom sanity check for Boost."""
shlib_ext = get_shared_lib_ext()

custom_paths = {
'files': ['lib/libboost_system.%s' % shlib_ext],
'files': [],
'dirs': ['include/boost']
}
if not self.cfg['only_python_bindings']:
custom_paths['files'].append(os.path.join('lib', 'libboost_system.%s' % shlib_ext))

if self.cfg['boost_mpi']:
custom_paths["files"].append('lib/libboost_mpi.%s' % shlib_ext)
custom_paths['files'].append(os.path.join('lib', 'libboost_mpi.%s' % shlib_ext))

if get_software_root('Python'):
pymajorver = get_software_version('Python').split('.')[0]
pyminorver = get_software_version('Python').split('.')[1]
Expand All @@ -257,11 +252,13 @@ def sanity_check_step(self):
suffix = pymajorver
else:
suffix = ''
custom_paths["files"].append('lib/libboost_python%s.%s' % (suffix, shlib_ext))
custom_paths['files'].append(os.path.join('lib', 'libboost_python%s.%s' % (suffix, shlib_ext)))

if self.cfg['boost_multi_thread']:
custom_paths["files"].append('lib/libboost_thread-mt.%s' % shlib_ext)
custom_paths['files'].append(os.path.join('lib', 'libboost_thread-mt.%s' % shlib_ext))

if self.cfg['boost_mpi'] and self.cfg['boost_multi_thread']:
custom_paths["files"].append('lib/libboost_mpi-mt.%s' % shlib_ext)
custom_paths['files'].append(os.path.join('lib', 'libboost_mpi-mt.%s' % shlib_ext))

super(EB_Boost, self).sanity_check_step(custom_paths=custom_paths)

Expand Down

0 comments on commit cf5eeab

Please sign in to comment.