Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions easybuild/easyblocks/p/petsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def __init__(self, *args, **kwargs):
self.prefix_lib = ''
self.prefix_bin = ''

self.with_python = False

if self.cfg['sourceinstall']:
self.prefix_inc = self.petsc_subdir
self.prefix_lib = os.path.join(self.petsc_subdir, self.petsc_arch)
Expand Down Expand Up @@ -89,6 +91,17 @@ def make_builddir(self):

super(EB_PETSc, self).make_builddir()

def prepare_step(self, *args, **kwargs):
"""Prepare build environment."""

super(EB_PETSc, self).prepare_step(*args, **kwargs)

# build with Python support if Python is loaded as a non-build (runtime) dependency
build_deps = self.cfg.dependencies(build_only=True)
if get_software_root('Python') and not any(x['name'] == 'Python' for x in build_deps):
self.with_python = True
self.log.info("Python included as runtime dependency, so enabling Python support")

def configure_step(self):
"""
Configure PETSc by setting configure options and running configure script.
Expand Down Expand Up @@ -155,12 +168,19 @@ def configure_step(self):
papi_inc_file, papi_lib)

# Python extensions_step
if get_software_root('Python'):
self.cfg.update('configopts', '--with-numpy=1')
if self.with_python:

# enable numpy support, but only if numpy is available
(_, ec) = run_cmd("python -c 'import numpy'", log_all=True, simple=False)
if ec == 0:
self.cfg.update('configopts', '--with-numpy=1')

with_mpi4py_opt = '--with-mpi4py'
if self.cfg['shared_libs'] and with_mpi4py_opt not in self.cfg['configopts']:
self.cfg.update('configopts', '%s=1' % with_mpi4py_opt)
# enable mpi4py support, but only if mpi4py is available
(_, ec) = run_cmd("python -c 'import mpi4py'", log_all=True, simple=False)
if ec == 0:
with_mpi4py_opt = '--with-mpi4py'
if self.cfg['shared_libs'] and with_mpi4py_opt not in self.cfg['configopts']:
self.cfg.update('configopts', '%s=1' % with_mpi4py_opt)

# FFTW, ScaLAPACK (and BLACS for older PETSc versions)
deps = ["FFTW", "ScaLAPACK"]
Expand Down Expand Up @@ -190,7 +210,7 @@ def configure_step(self):
# filter out deps handled seperately
sep_deps = ['BLACS', 'BLAS', 'CMake', 'FFTW', 'LAPACK', 'numpy',
'mpi4py', 'papi', 'ScaLAPACK', 'SciPy-bundle', 'SuiteSparse']
depfilter = self.cfg.builddependencies() + sep_deps
depfilter = [d['name'] for d in self.cfg.builddependencies()] + sep_deps

deps = [dep['name'] for dep in self.cfg.dependencies() if not dep['name'] in depfilter]
for dep in deps:
Expand Down Expand Up @@ -353,7 +373,7 @@ def sanity_check_step(self):
custom_paths['dirs'].append(os.path.join(self.prefix_lib, 'lib', 'petsc', 'conf'))

custom_commands = []
if get_software_root('Python'):
if self.with_python:
custom_commands.append("python -m PetscBinaryIO --help")

super(EB_PETSc, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)