Skip to content

Commit

Permalink
only build PETSc with Python support if Python is included as a non-b…
Browse files Browse the repository at this point in the history
…uild dependency
  • Loading branch information
boegel committed Jan 4, 2021
1 parent 316bde8 commit 2c5977c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 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,7 +168,7 @@ def configure_step(self):
papi_inc_file, papi_lib)

# Python extensions_step
if get_software_root('Python'):
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)
Expand Down Expand Up @@ -360,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)

0 comments on commit 2c5977c

Please sign in to comment.