Add --configure-args/vars support to RPackage (#4289)
* Add --configure-args/vars support to RPackage * Docstring formatting change
This commit is contained in:
@@ -30,7 +30,10 @@
|
|||||||
|
|
||||||
|
|
||||||
class RPackage(PackageBase):
|
class RPackage(PackageBase):
|
||||||
"""Specialized class for packages that are built using R
|
"""Specialized class for packages that are built using R.
|
||||||
|
|
||||||
|
For more information on the R build system, see:
|
||||||
|
https://stat.ethz.ch/R-manual/R-devel/library/utils/html/INSTALL.html
|
||||||
|
|
||||||
This class provides a single phase that can be overridden:
|
This class provides a single phase that can be overridden:
|
||||||
|
|
||||||
@@ -49,12 +52,37 @@ class RPackage(PackageBase):
|
|||||||
|
|
||||||
depends_on('r', type=('build', 'run'))
|
depends_on('r', type=('build', 'run'))
|
||||||
|
|
||||||
|
def configure_args(self, spec, prefix):
|
||||||
|
"""Arguments to pass to install via ``--configure-args``."""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def configure_vars(self, spec, prefix):
|
||||||
|
"""Arguments to pass to install via ``--configure-vars``."""
|
||||||
|
return []
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
"""Installs an R package."""
|
"""Installs an R package."""
|
||||||
inspect.getmodule(self).R(
|
|
||||||
'CMD', 'INSTALL',
|
config_args = self.configure_args(spec, prefix)
|
||||||
|
config_vars = self.configure_vars(spec, prefix)
|
||||||
|
|
||||||
|
args = [
|
||||||
|
'CMD',
|
||||||
|
'INSTALL'
|
||||||
|
]
|
||||||
|
|
||||||
|
if config_args:
|
||||||
|
args.append('--configure-args={0}'.format(' '.join(config_args)))
|
||||||
|
|
||||||
|
if config_vars:
|
||||||
|
args.append('--configure-vars={0}'.format(' '.join(config_vars)))
|
||||||
|
|
||||||
|
args.extend([
|
||||||
'--library={0}'.format(self.module.r_lib_dir),
|
'--library={0}'.format(self.module.r_lib_dir),
|
||||||
self.stage.source_path)
|
self.stage.source_path
|
||||||
|
])
|
||||||
|
|
||||||
|
inspect.getmodule(self).R(*args)
|
||||||
|
|
||||||
# Check that self.prefix is there after installation
|
# Check that self.prefix is there after installation
|
||||||
run_after('install')(PackageBase.sanity_check_prefix)
|
run_after('install')(PackageBase.sanity_check_prefix)
|
||||||
|
@@ -265,7 +265,11 @@ class RPackageTemplate(PackageTemplate):
|
|||||||
# depends_on('r-foo', type=('build', 'run'))"""
|
# depends_on('r-foo', type=('build', 'run'))"""
|
||||||
|
|
||||||
body = """\
|
body = """\
|
||||||
# FIXME: Override install() if necessary."""
|
def configure_args(self, spec, prefix):
|
||||||
|
# FIXME: Add arguments to pass to install via --configure-args
|
||||||
|
# FIXME: If not needed delete this function
|
||||||
|
args = []
|
||||||
|
return args"""
|
||||||
|
|
||||||
def __init__(self, name, *args):
|
def __init__(self, name, *args):
|
||||||
# If the user provided `--name r-rcpp`, don't rename it r-r-rcpp
|
# If the user provided `--name r-rcpp`, don't rename it r-r-rcpp
|
||||||
|
@@ -38,18 +38,25 @@ class RRmpi(RPackage):
|
|||||||
depends_on('mpi')
|
depends_on('mpi')
|
||||||
depends_on('r@2.15.1:')
|
depends_on('r@2.15.1:')
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
# The following MPI types are not supported
|
||||||
if 'mpich' in spec:
|
conflicts('^intel-mpi')
|
||||||
Rmpi_type = 'MPICH'
|
conflicts('^intel-parallel-studio')
|
||||||
elif 'mvapich' in spec:
|
conflicts('^mvapich2')
|
||||||
Rmpi_type = 'MVAPICH'
|
conflicts('^spectrum-mpi')
|
||||||
else:
|
|
||||||
|
def configure_args(self, spec, prefix):
|
||||||
|
mpi_name = spec['mpi'].name
|
||||||
|
|
||||||
|
# The type of MPI. Supported values are:
|
||||||
|
# OPENMPI, LAM, MPICH, MPICH2, or CRAY
|
||||||
|
if mpi_name == 'openmpi':
|
||||||
Rmpi_type = 'OPENMPI'
|
Rmpi_type = 'OPENMPI'
|
||||||
|
elif mpi_name == 'mpich':
|
||||||
|
Rmpi_type = 'MPICH2'
|
||||||
|
else:
|
||||||
|
raise InstallError('Unsupported MPI type')
|
||||||
|
|
||||||
my_mpi = spec['mpi']
|
return [
|
||||||
|
'--with-Rmpi-type={0}'.format(Rmpi_type),
|
||||||
R('CMD', 'INSTALL',
|
'--with-mpi={0}'.format(spec['mpi'].prefix),
|
||||||
'--configure-args=--with-Rmpi-type=%s' % Rmpi_type +
|
]
|
||||||
' --with-mpi=%s' % my_mpi.prefix,
|
|
||||||
'--library={0}'.format(self.module.r_lib_dir),
|
|
||||||
self.stage.source_path)
|
|
||||||
|
Reference in New Issue
Block a user