Add build systems tutorial for SC17 (#6125)
* First draft for SC17 build systems portion Added tutorial_buildsystems.rst file as well as example files under the tutorial/ directory. * Remove floating ` * Add requested changes, and examples of subclasses Added in the requested changes to the documentation. Also added in information about the subclasses and the defaults that they provide. Also fixed some phrasing issues, formatting and punctuation. * Flake8 fixes and new files for classes Made flake8 fixes to pass tests and also added files to demonstrate code in the classes. * Minor edits Edits in formatting and made some sentence changes * Flake8 fixes More flake8 fixes * Flake8 fix * Change section order on tutorial and minor edits Placed the section at the appropriate section for the tutorial and then added some minor edits that were requested. * Add requested changes and more details Added more details to Cmake, Makefile and Python Packages. * Fixed formatting and minor edits * Fix doc build error
This commit is contained in:

committed by
Todd Gamblin

parent
9db7eaade8
commit
2f1cbb5caa
@@ -30,8 +30,7 @@ class Mpileaks(Package):
|
||||
MPI_Datatypes."""
|
||||
|
||||
homepage = "https://github.com/hpc/mpileaks"
|
||||
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
|
||||
|
||||
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" # NOQA
|
||||
version('1.0', '8838c574b39202a57d7c2d68692718aa')
|
||||
|
||||
# FIXME: Add dependencies if required.
|
||||
|
46
lib/spack/docs/tutorial/examples/Autotools/0.package.py
Normal file
46
lib/spack/docs/tutorial/examples/Autotools/0.package.py
Normal file
@@ -0,0 +1,46 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Mpileaks(AutoToolsPackage):
|
||||
"""Tool to detect and report leaked MPI objects like MPI_Requests and
|
||||
MPI_Datatypes."""
|
||||
|
||||
homepage = "https://github.com/hpc/mpileaks"
|
||||
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
|
||||
|
||||
version('1.0', '8838c574b39202a57d7c2d68692718aa')
|
||||
|
||||
depends_on("mpi")
|
||||
depends_on("adept-utils")
|
||||
depends_on("callpath")
|
||||
|
||||
def install(self, spec, prefix):
|
||||
configure("--prefix=" + prefix,
|
||||
"--with-adept-utils=" + spec['adept-utils'].prefix,
|
||||
"--with-callpath=" + spec['callpath'].prefix)
|
||||
make()
|
||||
make("install")
|
44
lib/spack/docs/tutorial/examples/Autotools/1.package.py
Normal file
44
lib/spack/docs/tutorial/examples/Autotools/1.package.py
Normal file
@@ -0,0 +1,44 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Mpileaks(AutoToolsPackage):
|
||||
"""Tool to detect and report leaked MPI objects like MPI_Requests and
|
||||
MPI_Datatypes."""
|
||||
|
||||
homepage = "https://github.com/hpc/mpileaks"
|
||||
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
|
||||
|
||||
version('1.0', '8838c574b39202a57d7c2d68692718aa')
|
||||
|
||||
depends_on("mpi")
|
||||
depends_on("adept-utils")
|
||||
depends_on("callpath")
|
||||
|
||||
def configure_args(self):
|
||||
args = ["--with-adept-utils=" + spec['adept-utils'].prefix,
|
||||
"--with-callpath=" + spec['callpath'].prefix]
|
||||
return args
|
460
lib/spack/docs/tutorial/examples/Autotools/autotools_class.py
Normal file
460
lib/spack/docs/tutorial/examples/Autotools/autotools_class.py
Normal file
@@ -0,0 +1,460 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
import stat
|
||||
from subprocess import PIPE
|
||||
from subprocess import check_call
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import working_dir, join_path, force_remove
|
||||
from spack.package import PackageBase, run_after, run_before
|
||||
from spack.util.executable import Executable
|
||||
|
||||
|
||||
class AutotoolsPackage(PackageBase):
|
||||
"""Specialized class for packages built using GNU Autotools.
|
||||
|
||||
This class provides four phases that can be overridden:
|
||||
|
||||
1. :py:meth:`~.AutotoolsPackage.autoreconf`
|
||||
2. :py:meth:`~.AutotoolsPackage.configure`
|
||||
3. :py:meth:`~.AutotoolsPackage.build`
|
||||
4. :py:meth:`~.AutotoolsPackage.install`
|
||||
|
||||
They all have sensible defaults and for many packages the only thing
|
||||
necessary will be to override the helper method
|
||||
:py:meth:`~.AutotoolsPackage.configure_args`.
|
||||
For a finer tuning you may also override:
|
||||
|
||||
+-----------------------------------------------+--------------------+
|
||||
| **Method** | **Purpose** |
|
||||
+===============================================+====================+
|
||||
| :py:attr:`~.AutotoolsPackage.build_targets` | Specify ``make`` |
|
||||
| | targets for the |
|
||||
| | build phase |
|
||||
+-----------------------------------------------+--------------------+
|
||||
| :py:attr:`~.AutotoolsPackage.install_targets` | Specify ``make`` |
|
||||
| | targets for the |
|
||||
| | install phase |
|
||||
+-----------------------------------------------+--------------------+
|
||||
| :py:meth:`~.AutotoolsPackage.check` | Run build time |
|
||||
| | tests if required |
|
||||
+-----------------------------------------------+--------------------+
|
||||
|
||||
"""
|
||||
#: Phases of a GNU Autotools package
|
||||
phases = ['autoreconf', 'configure', 'build', 'install']
|
||||
#: This attribute is used in UI queries that need to know the build
|
||||
#: system base class
|
||||
build_system_class = 'AutotoolsPackage'
|
||||
#: Whether or not to update ``config.guess`` on old architectures
|
||||
patch_config_guess = True
|
||||
|
||||
#: Targets for ``make`` during the :py:meth:`~.AutotoolsPackage.build`
|
||||
#: phase
|
||||
build_targets = []
|
||||
#: Targets for ``make`` during the :py:meth:`~.AutotoolsPackage.install`
|
||||
#: phase
|
||||
install_targets = ['install']
|
||||
|
||||
#: Callback names for build-time test
|
||||
build_time_test_callbacks = ['check']
|
||||
|
||||
#: Callback names for install-time test
|
||||
install_time_test_callbacks = ['installcheck']
|
||||
|
||||
#: Set to true to force the autoreconf step even if configure is present
|
||||
force_autoreconf = False
|
||||
#: Options to be passed to autoreconf when using the default implementation
|
||||
autoreconf_extra_args = []
|
||||
|
||||
@run_after('autoreconf')
|
||||
def _do_patch_config_guess(self):
|
||||
"""Some packages ship with an older config.guess and need to have
|
||||
this updated when installed on a newer architecture. In particular,
|
||||
config.guess fails for PPC64LE for version prior to a 2013-06-10
|
||||
build date (automake 1.13.4)."""
|
||||
|
||||
if not self.patch_config_guess or not self.spec.satisfies(
|
||||
'target=ppc64le'
|
||||
):
|
||||
return
|
||||
my_config_guess = None
|
||||
config_guess = None
|
||||
if os.path.exists('config.guess'):
|
||||
# First search the top-level source directory
|
||||
my_config_guess = 'config.guess'
|
||||
else:
|
||||
# Then search in all sub directories.
|
||||
# We would like to use AC_CONFIG_AUX_DIR, but not all packages
|
||||
# ship with their configure.in or configure.ac.
|
||||
d = '.'
|
||||
dirs = [os.path.join(d, o) for o in os.listdir(d)
|
||||
if os.path.isdir(os.path.join(d, o))]
|
||||
for dirname in dirs:
|
||||
path = os.path.join(dirname, 'config.guess')
|
||||
if os.path.exists(path):
|
||||
my_config_guess = path
|
||||
|
||||
if my_config_guess is not None:
|
||||
try:
|
||||
check_call([my_config_guess], stdout=PIPE, stderr=PIPE)
|
||||
# The package's config.guess already runs OK, so just use it
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
return
|
||||
|
||||
# Look for a spack-installed automake package
|
||||
if 'automake' in self.spec:
|
||||
automake_path = os.path.join(self.spec['automake'].prefix, 'share',
|
||||
'automake-' +
|
||||
str(self.spec['automake'].version))
|
||||
path = os.path.join(automake_path, 'config.guess')
|
||||
if os.path.exists(path):
|
||||
config_guess = path
|
||||
# Look for the system's config.guess
|
||||
if config_guess is None and os.path.exists('/usr/share'):
|
||||
automake_dir = [s for s in os.listdir('/usr/share') if
|
||||
"automake" in s]
|
||||
if automake_dir:
|
||||
automake_path = os.path.join('/usr/share', automake_dir[0])
|
||||
path = os.path.join(automake_path, 'config.guess')
|
||||
if os.path.exists(path):
|
||||
config_guess = path
|
||||
if config_guess is not None:
|
||||
try:
|
||||
check_call([config_guess], stdout=PIPE, stderr=PIPE)
|
||||
mod = os.stat(my_config_guess).st_mode & 0o777 | stat.S_IWUSR
|
||||
os.chmod(my_config_guess, mod)
|
||||
shutil.copyfile(config_guess, my_config_guess)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
raise RuntimeError('Failed to find suitable config.guess')
|
||||
|
||||
@property
|
||||
def configure_directory(self):
|
||||
"""Returns the directory where 'configure' resides.
|
||||
|
||||
:return: directory where to find configure
|
||||
"""
|
||||
return self.stage.source_path
|
||||
|
||||
@property
|
||||
def configure_abs_path(self):
|
||||
# Absolute path to configure
|
||||
configure_abs_path = join_path(
|
||||
os.path.abspath(self.configure_directory), 'configure'
|
||||
)
|
||||
return configure_abs_path
|
||||
|
||||
@property
|
||||
def build_directory(self):
|
||||
"""Override to provide another place to build the package"""
|
||||
return self.configure_directory
|
||||
|
||||
def default_flag_handler(self, spack_env, flag_val):
|
||||
# Relies on being the first thing that can affect the spack_env
|
||||
# EnvironmentModification after it is instantiated or no other
|
||||
# method trying to affect these variables. Currently both are true
|
||||
# flag_val is a tuple (flag, value_list).
|
||||
spack_env.set(flag_val[0].upper(),
|
||||
' '.join(flag_val[1]))
|
||||
return []
|
||||
|
||||
@run_before('autoreconf')
|
||||
def delete_configure_to_force_update(self):
|
||||
if self.force_autoreconf:
|
||||
force_remove(self.configure_abs_path)
|
||||
|
||||
def autoreconf(self, spec, prefix):
|
||||
"""Not needed usually, configure should be already there"""
|
||||
# If configure exists nothing needs to be done
|
||||
if os.path.exists(self.configure_abs_path):
|
||||
return
|
||||
# Else try to regenerate it
|
||||
autotools = ['m4', 'autoconf', 'automake', 'libtool']
|
||||
missing = [x for x in autotools if x not in spec]
|
||||
if missing:
|
||||
msg = 'Cannot generate configure: missing dependencies {0}'
|
||||
raise RuntimeError(msg.format(missing))
|
||||
tty.msg('Configure script not found: trying to generate it')
|
||||
tty.warn('*********************************************************')
|
||||
tty.warn('* If the default procedure fails, consider implementing *')
|
||||
tty.warn('* a custom AUTORECONF phase in the package *')
|
||||
tty.warn('*********************************************************')
|
||||
with working_dir(self.configure_directory):
|
||||
m = inspect.getmodule(self)
|
||||
# This part should be redundant in principle, but
|
||||
# won't hurt
|
||||
m.libtoolize()
|
||||
m.aclocal()
|
||||
# This line is what is needed most of the time
|
||||
# --install, --verbose, --force
|
||||
autoreconf_args = ['-ivf']
|
||||
if 'pkg-config' in spec:
|
||||
autoreconf_args += [
|
||||
'-I',
|
||||
join_path(spec['pkg-config'].prefix, 'share', 'aclocal'),
|
||||
]
|
||||
autoreconf_args += self.autoreconf_extra_args
|
||||
m.autoreconf(*autoreconf_args)
|
||||
|
||||
@run_after('autoreconf')
|
||||
def set_configure_or_die(self):
|
||||
"""Checks the presence of a ``configure`` file after the
|
||||
autoreconf phase. If it is found sets a module attribute
|
||||
appropriately, otherwise raises an error.
|
||||
|
||||
:raises RuntimeError: if a configure script is not found in
|
||||
:py:meth:`~AutotoolsPackage.configure_directory`
|
||||
"""
|
||||
# Check if a configure script is there. If not raise a RuntimeError.
|
||||
if not os.path.exists(self.configure_abs_path):
|
||||
msg = 'configure script not found in {0}'
|
||||
raise RuntimeError(msg.format(self.configure_directory))
|
||||
|
||||
# Monkey-patch the configure script in the corresponding module
|
||||
inspect.getmodule(self).configure = Executable(
|
||||
self.configure_abs_path
|
||||
)
|
||||
|
||||
def configure_args(self):
|
||||
"""Produces a list containing all the arguments that must be passed to
|
||||
configure, except ``--prefix`` which will be pre-pended to the list.
|
||||
|
||||
:return: list of arguments for configure
|
||||
"""
|
||||
return []
|
||||
|
||||
def configure(self, spec, prefix):
|
||||
"""Runs configure with the arguments specified in
|
||||
:py:meth:`~.AutotoolsPackage.configure_args`
|
||||
and an appropriately set prefix.
|
||||
"""
|
||||
options = ['--prefix={0}'.format(prefix)] + self.configure_args()
|
||||
|
||||
with working_dir(self.build_directory, create=True):
|
||||
inspect.getmodule(self).configure(*options)
|
||||
|
||||
def build(self, spec, prefix):
|
||||
"""Makes the build targets specified by
|
||||
:py:attr:``~.AutotoolsPackage.build_targets``
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
inspect.getmodule(self).make(*self.build_targets)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
"""Makes the install targets specified by
|
||||
:py:attr:``~.AutotoolsPackage.install_targets``
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
inspect.getmodule(self).make(*self.install_targets)
|
||||
|
||||
run_after('build')(PackageBase._run_default_build_time_test_callbacks)
|
||||
|
||||
def check(self):
|
||||
"""Searches the Makefile for targets ``test`` and ``check``
|
||||
and runs them if found.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
self._if_make_target_execute('test')
|
||||
self._if_make_target_execute('check')
|
||||
|
||||
def _activate_or_not(
|
||||
self,
|
||||
name,
|
||||
activation_word,
|
||||
deactivation_word,
|
||||
activation_value=None
|
||||
):
|
||||
"""This function contains the current implementation details of
|
||||
:py:meth:`~.AutotoolsPackage.with_or_without` and
|
||||
:py:meth:`~.AutotoolsPackage.enable_or_disable`.
|
||||
|
||||
Args:
|
||||
name (str): name of the variant that is being processed
|
||||
activation_word (str): the default activation word ('with' in the
|
||||
case of ``with_or_without``)
|
||||
deactivation_word (str): the default deactivation word ('without'
|
||||
in the case of ``with_or_without``)
|
||||
activation_value (callable): callable that accepts a single
|
||||
value. This value is either one of the allowed values for a
|
||||
multi-valued variant or the name of a bool-valued variant.
|
||||
Returns the parameter to be used when the value is activated.
|
||||
|
||||
The special value 'prefix' can also be assigned and will return
|
||||
``spec[name].prefix`` as activation parameter.
|
||||
|
||||
Examples:
|
||||
|
||||
Given a package with:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
variant('foo', values=('x', 'y'), description='')
|
||||
variant('bar', default=True, description='')
|
||||
|
||||
calling this function like:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
_activate_or_not(
|
||||
'foo', 'with', 'without', activation_value='prefix'
|
||||
)
|
||||
_activate_or_not('bar', 'with', 'without')
|
||||
|
||||
will generate the following configuration options:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
--with-x=<prefix-to-x> --without-y --with-bar
|
||||
|
||||
for ``<spec-name> foo=x +bar``
|
||||
|
||||
Returns:
|
||||
list of strings that corresponds to the activation/deactivation
|
||||
of the variant that has been processed
|
||||
|
||||
Raises:
|
||||
KeyError: if name is not among known variants
|
||||
"""
|
||||
spec = self.spec
|
||||
args = []
|
||||
|
||||
if activation_value == 'prefix':
|
||||
activation_value = lambda x: spec[x].prefix
|
||||
|
||||
# Defensively look that the name passed as argument is among
|
||||
# variants
|
||||
if name not in self.variants:
|
||||
msg = '"{0}" is not a variant of "{1}"'
|
||||
raise KeyError(msg.format(name, self.name))
|
||||
|
||||
# Create a list of pairs. Each pair includes a configuration
|
||||
# option and whether or not that option is activated
|
||||
if set(self.variants[name].values) == set((True, False)):
|
||||
# BoolValuedVariant carry information about a single option.
|
||||
# Nonetheless, for uniformity of treatment we'll package them
|
||||
# in an iterable of one element.
|
||||
condition = '+{name}'.format(name=name)
|
||||
options = [(name, condition in spec)]
|
||||
else:
|
||||
condition = '{name}={value}'
|
||||
options = [
|
||||
(value, condition.format(name=name, value=value) in spec)
|
||||
for value in self.variants[name].values
|
||||
]
|
||||
|
||||
# For each allowed value in the list of values
|
||||
for option_value, activated in options:
|
||||
# Search for an override in the package for this value
|
||||
override_name = '{0}_or_{1}_{2}'.format(
|
||||
activation_word, deactivation_word, option_value
|
||||
)
|
||||
line_generator = getattr(self, override_name, None)
|
||||
# If not available use a sensible default
|
||||
if line_generator is None:
|
||||
def _default_generator(is_activated):
|
||||
if is_activated:
|
||||
line = '--{0}-{1}'.format(
|
||||
activation_word, option_value
|
||||
)
|
||||
if activation_value is not None and activation_value(option_value): # NOQA=ignore=E501
|
||||
line += '={0}'.format(
|
||||
activation_value(option_value)
|
||||
)
|
||||
return line
|
||||
return '--{0}-{1}'.format(deactivation_word, option_value)
|
||||
line_generator = _default_generator
|
||||
args.append(line_generator(activated))
|
||||
return args
|
||||
|
||||
def with_or_without(self, name, activation_value=None):
|
||||
"""Inspects a variant and returns the arguments that activate
|
||||
or deactivate the selected feature(s) for the configure options.
|
||||
|
||||
This function works on all type of variants. For bool-valued variants
|
||||
it will return by default ``--with-{name}`` or ``--without-{name}``.
|
||||
For other kinds of variants it will cycle over the allowed values and
|
||||
return either ``--with-{value}`` or ``--without-{value}``.
|
||||
|
||||
If activation_value is given, then for each possible value of the
|
||||
variant, the option ``--with-{value}=activation_value(value)`` or
|
||||
``--without-{value}`` will be added depending on whether or not
|
||||
``variant=value`` is in the spec.
|
||||
|
||||
Args:
|
||||
name (str): name of a valid multi-valued variant
|
||||
activation_value (callable): callable that accepts a single
|
||||
value and returns the parameter to be used leading to an entry
|
||||
of the type ``--with-{name}={parameter}``.
|
||||
|
||||
The special value 'prefix' can also be assigned and will return
|
||||
``spec[name].prefix`` as activation parameter.
|
||||
|
||||
Returns:
|
||||
list of arguments to configure
|
||||
"""
|
||||
return self._activate_or_not(name, 'with', 'without', activation_value)
|
||||
|
||||
def enable_or_disable(self, name, activation_value=None):
|
||||
"""Same as :py:meth:`~.AutotoolsPackage.with_or_without` but substitute
|
||||
``with`` with ``enable`` and ``without`` with ``disable``.
|
||||
|
||||
Args:
|
||||
name (str): name of a valid multi-valued variant
|
||||
activation_value (callable): if present accepts a single value
|
||||
and returns the parameter to be used leading to an entry of the
|
||||
type ``--enable-{name}={parameter}``
|
||||
|
||||
The special value 'prefix' can also be assigned and will return
|
||||
``spec[name].prefix`` as activation parameter.
|
||||
|
||||
Returns:
|
||||
list of arguments to configure
|
||||
"""
|
||||
return self._activate_or_not(
|
||||
name, 'enable', 'disable', activation_value
|
||||
)
|
||||
|
||||
run_after('install')(PackageBase._run_default_install_time_test_callbacks)
|
||||
|
||||
def installcheck(self):
|
||||
"""Searches the Makefile for an ``installcheck`` target
|
||||
and runs it if found.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
self._if_make_target_execute('installcheck')
|
||||
|
||||
# Check that self.prefix is there after installation
|
||||
run_after('install')(PackageBase.sanity_check_prefix)
|
60
lib/spack/docs/tutorial/examples/Cmake/0.package.py
Normal file
60
lib/spack/docs/tutorial/examples/Cmake/0.package.py
Normal file
@@ -0,0 +1,60 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
#
|
||||
# This is a template package file for Spack. We've put "FIXME"
|
||||
# next to all the things you'll want to change. Once you've handled
|
||||
# them, you can save this file and test your package like this:
|
||||
#
|
||||
# spack install callpath
|
||||
#
|
||||
# You can edit this file again by typing:
|
||||
#
|
||||
# spack edit callpath
|
||||
#
|
||||
# See the Spack documentation for more information on packaging.
|
||||
# If you submit this package back to Spack as a pull request,
|
||||
# please first remove this boilerplate and all FIXME comments.
|
||||
#
|
||||
from spack import *
|
||||
|
||||
|
||||
class Callpath(CMakePackage):
|
||||
"""FIXME: Put a proper description of your package here."""
|
||||
|
||||
# FIXME: Add a proper url for your package's homepage here.
|
||||
homepage = "http://www.example.com"
|
||||
url = "https://github.com/llnl/callpath/archive/v1.0.1.tar.gz"
|
||||
|
||||
version('1.0.3', 'c89089b3f1c1ba47b09b8508a574294a')
|
||||
|
||||
# FIXME: Add dependencies if required.
|
||||
# depends_on('foo')
|
||||
|
||||
def cmake_args(self):
|
||||
# FIXME: Add arguments other than
|
||||
# FIXME: CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE
|
||||
# FIXME: If not needed delete this function
|
||||
args = []
|
||||
return args
|
42
lib/spack/docs/tutorial/examples/Cmake/1.package.py
Normal file
42
lib/spack/docs/tutorial/examples/Cmake/1.package.py
Normal file
@@ -0,0 +1,42 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Callpath(CMakePackage):
|
||||
"""Library for representing callpaths consistently in
|
||||
distributed-memory performance tools."""
|
||||
|
||||
homepage = "https://github.com/llnl/callpath"
|
||||
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
|
||||
|
||||
version('1.0.3', 'c89089b3f1c1ba47b09b8508a574294a')
|
||||
|
||||
depends_on("elf", type="link")
|
||||
depends_on("libdwarf")
|
||||
depends_on("dyninst")
|
||||
depends_on("adept-utils")
|
||||
depends_on("mpi")
|
||||
depends_on("cmake@2.8:", type="build")
|
52
lib/spack/docs/tutorial/examples/Cmake/2.package.py
Normal file
52
lib/spack/docs/tutorial/examples/Cmake/2.package.py
Normal file
@@ -0,0 +1,52 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Callpath(CMakePackage):
|
||||
"""Library for representing callpaths consistently in
|
||||
distributed-memory performance tools."""
|
||||
|
||||
homepage = "https://github.com/llnl/callpath"
|
||||
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
|
||||
|
||||
version('1.0.3', 'c89089b3f1c1ba47b09b8508a574294a')
|
||||
|
||||
depends_on("elf", type="link")
|
||||
depends_on("libdwarf")
|
||||
depends_on("dyninst")
|
||||
depends_on("adept-utils")
|
||||
depends_on("mpi")
|
||||
depends_on("cmake@2.8:", type="build")
|
||||
|
||||
def cmake_args(self):
|
||||
args = ["-DCALLPATH_WALKER=dyninst"]
|
||||
|
||||
if self.spec.satisfies("^dyninst@9.3.0:"):
|
||||
std.flag = self.compiler.cxx_flag
|
||||
args.append("-DCMAKE_CXX_FLAGS='{0}' -fpermissive'".format(
|
||||
std_flag))
|
||||
|
||||
return args
|
224
lib/spack/docs/tutorial/examples/Cmake/cmake_class.py
Normal file
224
lib/spack/docs/tutorial/examples/Cmake/cmake_class.py
Normal file
@@ -0,0 +1,224 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import platform
|
||||
|
||||
import spack.build_environment
|
||||
from llnl.util.filesystem import working_dir, join_path
|
||||
from spack.util.environment import filter_system_paths
|
||||
from spack.directives import depends_on, variant
|
||||
from spack.package import PackageBase, InstallError, run_after
|
||||
|
||||
|
||||
class CMakePackage(PackageBase):
|
||||
"""Specialized class for packages built using CMake
|
||||
|
||||
For more information on the CMake build system, see:
|
||||
https://cmake.org/cmake/help/latest/
|
||||
|
||||
This class provides three phases that can be overridden:
|
||||
|
||||
1. :py:meth:`~.CMakePackage.cmake`
|
||||
2. :py:meth:`~.CMakePackage.build`
|
||||
3. :py:meth:`~.CMakePackage.install`
|
||||
|
||||
They all have sensible defaults and for many packages the only thing
|
||||
necessary will be to override :py:meth:`~.CMakePackage.cmake_args`.
|
||||
For a finer tuning you may also override:
|
||||
|
||||
+-----------------------------------------------+--------------------+
|
||||
| **Method** | **Purpose** |
|
||||
+===============================================+====================+
|
||||
| :py:meth:`~.CMakePackage.root_cmakelists_dir` | Location of the |
|
||||
| | root CMakeLists.txt|
|
||||
+-----------------------------------------------+--------------------+
|
||||
| :py:meth:`~.CMakePackage.build_directory` | Directory where to |
|
||||
| | build the package |
|
||||
+-----------------------------------------------+--------------------+
|
||||
|
||||
|
||||
"""
|
||||
#: Phases of a CMake package
|
||||
phases = ['cmake', 'build', 'install']
|
||||
#: This attribute is used in UI queries that need to know the build
|
||||
#: system base class
|
||||
build_system_class = 'CMakePackage'
|
||||
|
||||
build_targets = []
|
||||
install_targets = ['install']
|
||||
|
||||
build_time_test_callbacks = ['check']
|
||||
|
||||
#: The build system generator to use.
|
||||
#:
|
||||
#: See ``cmake --help`` for a list of valid generators.
|
||||
#: Currently, "Unix Makefiles" and "Ninja" are the only generators
|
||||
#: that Spack supports. Defaults to "Unix Makefiles".
|
||||
#:
|
||||
#: See https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html
|
||||
#: for more information.
|
||||
generator = 'Unix Makefiles'
|
||||
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
|
||||
variant('build_type', default='RelWithDebInfo',
|
||||
description='CMake build type',
|
||||
values=('Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel'))
|
||||
|
||||
depends_on('cmake', type='build')
|
||||
|
||||
@property
|
||||
def root_cmakelists_dir(self):
|
||||
"""The relative path to the directory containing CMakeLists.txt
|
||||
|
||||
This path is relative to the root of the extracted tarball,
|
||||
not to the ``build_directory``. Defaults to the current directory.
|
||||
|
||||
:return: directory containing CMakeLists.txt
|
||||
"""
|
||||
return self.stage.source_path
|
||||
|
||||
@property
|
||||
def std_cmake_args(self):
|
||||
"""Standard cmake arguments provided as a property for
|
||||
convenience of package writers
|
||||
|
||||
:return: standard cmake arguments
|
||||
"""
|
||||
# standard CMake arguments
|
||||
return CMakePackage._std_args(self)
|
||||
|
||||
@staticmethod
|
||||
def _std_args(pkg):
|
||||
"""Computes the standard cmake arguments for a generic package"""
|
||||
try:
|
||||
generator = pkg.generator
|
||||
except AttributeError:
|
||||
generator = 'Unix Makefiles'
|
||||
|
||||
# Make sure a valid generator was chosen
|
||||
valid_generators = ['Unix Makefiles', 'Ninja']
|
||||
if generator not in valid_generators:
|
||||
msg = "Invalid CMake generator: '{0}'\n".format(generator)
|
||||
msg += "CMakePackage currently supports the following "
|
||||
msg += "generators: '{0}'".format("', '".join(valid_generators))
|
||||
raise InstallError(msg)
|
||||
|
||||
try:
|
||||
build_type = pkg.spec.variants['build_type'].value
|
||||
except KeyError:
|
||||
build_type = 'RelWithDebInfo'
|
||||
|
||||
args = [
|
||||
'-G', generator,
|
||||
'-DCMAKE_INSTALL_PREFIX:PATH={0}'.format(pkg.prefix),
|
||||
'-DCMAKE_BUILD_TYPE:STRING={0}'.format(build_type),
|
||||
'-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON'
|
||||
]
|
||||
|
||||
if platform.mac_ver()[0]:
|
||||
args.append('-DCMAKE_FIND_FRAMEWORK:STRING=LAST')
|
||||
|
||||
# Set up CMake rpath
|
||||
args.append('-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=FALSE')
|
||||
rpaths = ':'.join(spack.build_environment.get_rpaths(pkg))
|
||||
args.append('-DCMAKE_INSTALL_RPATH:STRING={0}'.format(rpaths))
|
||||
# CMake's find_package() looks in CMAKE_PREFIX_PATH first, help CMake
|
||||
# to find immediate link dependencies in right places:
|
||||
deps = [d.prefix for d in
|
||||
pkg.spec.dependencies(deptype=('build', 'link'))]
|
||||
deps = filter_system_paths(deps)
|
||||
args.append('-DCMAKE_PREFIX_PATH:STRING={0}'.format(';'.join(deps)))
|
||||
return args
|
||||
|
||||
@property
|
||||
def build_directory(self):
|
||||
"""Returns the directory to use when building the package
|
||||
|
||||
:return: directory where to build the package
|
||||
"""
|
||||
return join_path(self.stage.source_path, 'spack-build')
|
||||
|
||||
def default_flag_handler(self, spack_env, flag_val):
|
||||
# Relies on being the first thing that can affect the spack_env
|
||||
# EnvironmentModification after it is instantiated or no other
|
||||
# method trying to affect these variables. Currently both are true
|
||||
# flag_val is a tuple (flag, value_list)
|
||||
spack_env.set(flag_val[0].upper(),
|
||||
' '.join(flag_val[1]))
|
||||
return []
|
||||
|
||||
def cmake_args(self):
|
||||
"""Produces a list containing all the arguments that must be passed to
|
||||
cmake, except:
|
||||
|
||||
* CMAKE_INSTALL_PREFIX
|
||||
* CMAKE_BUILD_TYPE
|
||||
|
||||
which will be set automatically.
|
||||
|
||||
:return: list of arguments for cmake
|
||||
"""
|
||||
return []
|
||||
|
||||
def cmake(self, spec, prefix):
|
||||
"""Runs ``cmake`` in the build directory"""
|
||||
options = [os.path.abspath(self.root_cmakelists_dir)]
|
||||
options += self.std_cmake_args
|
||||
options += self.cmake_args()
|
||||
with working_dir(self.build_directory, create=True):
|
||||
inspect.getmodule(self).cmake(*options)
|
||||
|
||||
def build(self, spec, prefix):
|
||||
"""Make the build targets"""
|
||||
with working_dir(self.build_directory):
|
||||
if self.generator == 'Unix Makefiles':
|
||||
inspect.getmodule(self).make(*self.build_targets)
|
||||
elif self.generator == 'Ninja':
|
||||
inspect.getmodule(self).ninja(*self.build_targets)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
"""Make the install targets"""
|
||||
with working_dir(self.build_directory):
|
||||
if self.generator == 'Unix Makefiles':
|
||||
inspect.getmodule(self).make(*self.install_targets)
|
||||
elif self.generator == 'Ninja':
|
||||
inspect.getmodule(self).ninja(*self.install_targets)
|
||||
|
||||
run_after('build')(PackageBase._run_default_build_time_test_callbacks)
|
||||
|
||||
def check(self):
|
||||
"""Searches the CMake-generated Makefile for the target ``test``
|
||||
and runs it if found.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
if self.generator == 'Unix Makefiles':
|
||||
self._if_make_target_execute('test')
|
||||
elif self.generator == 'Ninja':
|
||||
self._if_ninja_target_execute('test')
|
||||
|
||||
# Check that self.prefix is there after installation
|
||||
run_after('install')(PackageBase.sanity_check_prefix)
|
45
lib/spack/docs/tutorial/examples/Makefile/0.package.py
Normal file
45
lib/spack/docs/tutorial/examples/Makefile/0.package.py
Normal file
@@ -0,0 +1,45 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Bowtie(MakefilePackage):
|
||||
"""FIXME: Put a proper description of your package here."""
|
||||
|
||||
# FIXME: Add a proper url for your package's homepage here.
|
||||
homepage = "http://www.example.com"
|
||||
url = "https://downloads.sourceforge.net/project/bowtie-bio/bowtie/1.2.1.1/bowtie-1.2.1.1-src.zip"
|
||||
|
||||
version('1.2.1.1', 'ec06265730c5f587cd58bcfef6697ddf')
|
||||
|
||||
# FIXME: Add dependencies if required.
|
||||
# depends_on('foo')
|
||||
|
||||
def edit(self, spec, prefix):
|
||||
# FIXME: Edit the Makefile if necessary
|
||||
# FIXME: If not needed delete this function
|
||||
# makefile = FileFilter('Makefile')
|
||||
# makefile.filter('CC = .*', 'CC = cc')
|
||||
return
|
46
lib/spack/docs/tutorial/examples/Makefile/1.package.py
Normal file
46
lib/spack/docs/tutorial/examples/Makefile/1.package.py
Normal file
@@ -0,0 +1,46 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Bowtie(MakefilePackage):
|
||||
"""Bowtie is an ultrafast, memory efficient short read aligner
|
||||
for short DNA sequences (reads) from next-gen sequencers."""
|
||||
|
||||
homepage = "https://sourceforge.net/projects/bowtie-bio/"
|
||||
url = "https://downloads.sourceforge.net/project/bowtie-bio/bowtie/1.2.1.1/bowtie-1.2.1.1-src.zip"
|
||||
|
||||
version('1.2.1.1', 'ec06265730c5f587cd58bcfef6697ddf')
|
||||
|
||||
variant("tbb", default=False, description="Use Intel thread building block")
|
||||
|
||||
depends_on("tbb", when="+tbb")
|
||||
|
||||
def edit(self, spec, prefix):
|
||||
# FIXME: Edit the Makefile if necessary
|
||||
# FIXME: If not needed delete this function
|
||||
# makefile = FileFilter('Makefile')
|
||||
# makefile.filter('CC = .*', 'CC = cc')
|
||||
return
|
44
lib/spack/docs/tutorial/examples/Makefile/2.package.py
Normal file
44
lib/spack/docs/tutorial/examples/Makefile/2.package.py
Normal file
@@ -0,0 +1,44 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Bowtie(MakefilePackage):
|
||||
"""Bowtie is an ultrafast, memory efficient short read aligner
|
||||
for short DNA sequences (reads) from next-gen sequencers."""
|
||||
|
||||
homepage = "https://sourceforge.net/projects/bowtie-bio/"
|
||||
url = "https://downloads.sourceforge.net/project/bowtie-bio/bowtie/1.2.1.1/bowtie-1.2.1.1-src.zip"
|
||||
|
||||
version('1.2.1.1', 'ec06265730c5f587cd58bcfef6697ddf')
|
||||
|
||||
variant("tbb", default=False, description="Use Intel thread building block")
|
||||
|
||||
depends_on("tbb", when="+tbb")
|
||||
|
||||
def edit(self, spec, prefix):
|
||||
makefile = FileFilter("Makefile")
|
||||
makefile.filter('CC= .*', 'CC = ' + env['CC'])
|
||||
makefile.filter('CXX = .*', 'CXX = ' + env['CXX'])
|
53
lib/spack/docs/tutorial/examples/Makefile/3.package.py
Normal file
53
lib/spack/docs/tutorial/examples/Makefile/3.package.py
Normal file
@@ -0,0 +1,53 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class Bowtie(MakefilePackage):
|
||||
"""Bowtie is an ultrafast, memory efficient short read aligner
|
||||
for short DNA sequences (reads) from next-gen sequencers."""
|
||||
|
||||
homepage = "https://sourceforge.net/projects/bowtie-bio/"
|
||||
url = "https://downloads.sourceforge.net/project/bowtie-bio/bowtie/1.2.1.1/bowtie-1.2.1.1-src.zip"
|
||||
|
||||
version('1.2.1.1', 'ec06265730c5f587cd58bcfef6697ddf')
|
||||
|
||||
variant("tbb", default=False, description="Use Intel thread building block")
|
||||
|
||||
depends_on("tbb", when="+tbb")
|
||||
|
||||
def edit(self, spec, prefix):
|
||||
makefile = FileFilter("Makefile")
|
||||
makefile.filter('CC= .*', 'CC = ' + env['CC'])
|
||||
makefile.filter('CXX = .*', 'CXX = ' + env['CXX'])
|
||||
|
||||
def build(self, spec, prefix):
|
||||
if "+tbb" in spec:
|
||||
make()
|
||||
else:
|
||||
make("NO_TBB=1")
|
||||
|
||||
def install(self, spec, prefix):
|
||||
make('prefix={0}'.format(self.prefix), 'install')
|
129
lib/spack/docs/tutorial/examples/Makefile/makefile_class.py
Normal file
129
lib/spack/docs/tutorial/examples/Makefile/makefile_class.py
Normal file
@@ -0,0 +1,129 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
|
||||
import inspect
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import working_dir
|
||||
from spack.package import PackageBase, run_after
|
||||
|
||||
|
||||
class MakefilePackage(PackageBase):
|
||||
"""Specialized class for packages that are built using editable Makefiles
|
||||
|
||||
This class provides three phases that can be overridden:
|
||||
|
||||
1. :py:meth:`~.MakefilePackage.edit`
|
||||
2. :py:meth:`~.MakefilePackage.build`
|
||||
3. :py:meth:`~.MakefilePackage.install`
|
||||
|
||||
It is usually necessary to override the :py:meth:`~.MakefilePackage.edit`
|
||||
phase, while :py:meth:`~.MakefilePackage.build` and
|
||||
:py:meth:`~.MakefilePackage.install` have sensible defaults.
|
||||
For a finer tuning you may override:
|
||||
|
||||
+-----------------------------------------------+--------------------+
|
||||
| **Method** | **Purpose** |
|
||||
+===============================================+====================+
|
||||
| :py:attr:`~.MakefilePackage.build_targets` | Specify ``make`` |
|
||||
| | targets for the |
|
||||
| | build phase |
|
||||
+-----------------------------------------------+--------------------+
|
||||
| :py:attr:`~.MakefilePackage.install_targets` | Specify ``make`` |
|
||||
| | targets for the |
|
||||
| | install phase |
|
||||
+-----------------------------------------------+--------------------+
|
||||
| :py:meth:`~.MakefilePackage.build_directory` | Directory where the|
|
||||
| | Makefile is located|
|
||||
+-----------------------------------------------+--------------------+
|
||||
"""
|
||||
#: Phases of a package that is built with an hand-written Makefile
|
||||
phases = ['edit', 'build', 'install']
|
||||
#: This attribute is used in UI queries that need to know the build
|
||||
#: system base class
|
||||
build_system_class = 'MakefilePackage'
|
||||
|
||||
#: Targets for ``make`` during the :py:meth:`~.MakefilePackage.build`
|
||||
#: phase
|
||||
build_targets = []
|
||||
#: Targets for ``make`` during the :py:meth:`~.MakefilePackage.install`
|
||||
#: phase
|
||||
install_targets = ['install']
|
||||
|
||||
#: Callback names for build-time test
|
||||
build_time_test_callbacks = ['check']
|
||||
|
||||
#: Callback names for install-time test
|
||||
install_time_test_callbacks = ['installcheck']
|
||||
|
||||
@property
|
||||
def build_directory(self):
|
||||
"""Returns the directory containing the main Makefile
|
||||
|
||||
:return: build directory
|
||||
"""
|
||||
return self.stage.source_path
|
||||
|
||||
def edit(self, spec, prefix):
|
||||
"""Edits the Makefile before calling make. This phase cannot
|
||||
be defaulted.
|
||||
"""
|
||||
tty.msg('Using default implementation: skipping edit phase.')
|
||||
|
||||
def build(self, spec, prefix):
|
||||
"""Calls make, passing :py:attr:`~.MakefilePackage.build_targets`
|
||||
as targets.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
inspect.getmodule(self).make(*self.build_targets)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
"""Calls make, passing :py:attr:`~.MakefilePackage.install_targets`
|
||||
as targets.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
inspect.getmodule(self).make(*self.install_targets)
|
||||
|
||||
run_after('build')(PackageBase._run_default_build_time_test_callbacks)
|
||||
|
||||
def check(self):
|
||||
"""Searches the Makefile for targets ``test`` and ``check``
|
||||
and runs them if found.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
self._if_make_target_execute('test')
|
||||
self._if_make_target_execute('check')
|
||||
|
||||
run_after('install')(PackageBase._run_default_install_time_test_callbacks)
|
||||
|
||||
def installcheck(self):
|
||||
"""Searches the Makefile for an ``installcheck`` target
|
||||
and runs it if found.
|
||||
"""
|
||||
with working_dir(self.build_directory):
|
||||
self._if_make_target_execute('installcheck')
|
||||
|
||||
# Check that self.prefix is there after installation
|
||||
run_after('install')(PackageBase.sanity_check_prefix)
|
60
lib/spack/docs/tutorial/examples/PyPackage/0.package.py
Normal file
60
lib/spack/docs/tutorial/examples/PyPackage/0.package.py
Normal file
@@ -0,0 +1,60 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
#
|
||||
# This is a template package file for Spack. We've put "FIXME"
|
||||
# next to all the things you'll want to change. Once you've handled
|
||||
# them, you can save this file and test your package like this:
|
||||
#
|
||||
# spack install py-pandas
|
||||
#
|
||||
# You can edit this file again by typing:
|
||||
#
|
||||
# spack edit py-pandas
|
||||
#
|
||||
# See the Spack documentation for more information on packaging.
|
||||
# If you submit this package back to Spack as a pull request,
|
||||
# please first remove this boilerplate and all FIXME comments.
|
||||
#
|
||||
from spack import *
|
||||
|
||||
|
||||
class PyPandas(PythonPackage):
|
||||
"""FIXME: Put a proper description of your package here."""
|
||||
|
||||
# FIXME: Add a proper url for your package's homepage here.
|
||||
homepage = "http://www.example.com"
|
||||
url = "https://pypi.io/packages/source/p/pandas/pandas-0.19.0.tar.gz"
|
||||
|
||||
version('0.19.0', 'bc9bb7188e510b5d44fbdd249698a2c3')
|
||||
|
||||
# FIXME: Add dependencies if required.
|
||||
# depends_on('py-setuptools', type='build')
|
||||
# depends_on('py-foo', type=('build', 'run'))
|
||||
|
||||
def build_args(self, spec, prefix):
|
||||
# FIXME: Add arguments other than --prefix
|
||||
# FIXME: If not needed delete this function
|
||||
args = []
|
||||
return args
|
51
lib/spack/docs/tutorial/examples/PyPackage/1.package.py
Normal file
51
lib/spack/docs/tutorial/examples/PyPackage/1.package.py
Normal file
@@ -0,0 +1,51 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
|
||||
|
||||
class PyPandas(PythonPackage):
|
||||
"""pandas is a Python package providing fast, flexible, and expressive
|
||||
data structures designed to make working with relational or
|
||||
labeled data both easy and intuitive. It aims to be the
|
||||
fundamental high-level building block for doing practical, real
|
||||
world data analysis in Python. Additionally, it has the broader
|
||||
goal of becoming the most powerful and flexible open source data
|
||||
analysis / manipulation tool available in any language.
|
||||
"""
|
||||
homepage = "http://pandas.pydata.org/"
|
||||
url = "https://pypi.io/packages/source/p/pandas/pandas-0.19.0.tar.gz"
|
||||
|
||||
version('0.19.0', 'bc9bb7188e510b5d44fbdd249698a2c3')
|
||||
version('0.18.0', 'f143762cd7a59815e348adf4308d2cf6')
|
||||
version('0.16.1', 'fac4f25748f9610a3e00e765474bdea8')
|
||||
version('0.16.0', 'bfe311f05dc0c351f8955fbd1e296e73')
|
||||
|
||||
depends_on('py-dateutil', type=('build', 'run'))
|
||||
depends_on('py-numpy', type=('build', 'run'))
|
||||
depends_on('py-setuptools', type='build')
|
||||
depends_on('py-cython', type='build')
|
||||
depends_on('py-pytz', type=('build', 'run'))
|
||||
depends_on('py-numexpr', type=('build', 'run'))
|
||||
depends_on('py-bottleneck', type=('build', 'run'))
|
@@ -0,0 +1,399 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
|
||||
import inspect
|
||||
import os
|
||||
|
||||
from spack.directives import depends_on, extends
|
||||
from spack.package import PackageBase, run_after
|
||||
|
||||
from llnl.util.filesystem import working_dir
|
||||
|
||||
|
||||
class PythonPackage(PackageBase):
|
||||
"""Specialized class for packages that are built using Python
|
||||
setup.py files
|
||||
|
||||
This class provides the following phases that can be overridden:
|
||||
|
||||
* build
|
||||
* build_py
|
||||
* build_ext
|
||||
* build_clib
|
||||
* build_scripts
|
||||
* clean
|
||||
* install
|
||||
* install_lib
|
||||
* install_headers
|
||||
* install_scripts
|
||||
* install_data
|
||||
* sdist
|
||||
* register
|
||||
* bdist
|
||||
* bdist_dumb
|
||||
* bdist_rpm
|
||||
* bdist_wininst
|
||||
* upload
|
||||
* check
|
||||
|
||||
These are all standard setup.py commands and can be found by running:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ python setup.py --help-commands
|
||||
|
||||
By default, only the 'build' and 'install' phases are run, but if you
|
||||
need to run more phases, simply modify your ``phases`` list like so:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
phases = ['build_ext', 'install', 'bdist']
|
||||
|
||||
Each phase provides a function <phase> that runs:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ python setup.py --no-user-cfg <phase>
|
||||
|
||||
Each phase also has a <phase_args> function that can pass arguments to
|
||||
this call. All of these functions are empty except for the ``install_args``
|
||||
function, which passes ``--prefix=/path/to/installation/directory``.
|
||||
|
||||
If you need to run a phase which is not a standard setup.py command,
|
||||
you'll need to define a function for it like so:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def configure(self, spec, prefix):
|
||||
self.setup_py('configure')
|
||||
"""
|
||||
# Default phases
|
||||
phases = ['build', 'install']
|
||||
|
||||
# Name of modules that the Python package provides
|
||||
# This is used to test whether or not the installation succeeded
|
||||
# These names generally come from running:
|
||||
#
|
||||
# >>> import setuptools
|
||||
# >>> setuptools.find_packages()
|
||||
#
|
||||
# in the source tarball directory
|
||||
import_modules = []
|
||||
|
||||
# To be used in UI queries that require to know which
|
||||
# build-system class we are using
|
||||
build_system_class = 'PythonPackage'
|
||||
|
||||
#: Callback names for build-time test
|
||||
build_time_test_callbacks = ['test']
|
||||
|
||||
#: Callback names for install-time test
|
||||
install_time_test_callbacks = ['import_module_test']
|
||||
|
||||
extends('python')
|
||||
|
||||
depends_on('python', type=('build', 'run'))
|
||||
|
||||
def setup_file(self):
|
||||
"""Returns the name of the setup file to use."""
|
||||
return 'setup.py'
|
||||
|
||||
@property
|
||||
def build_directory(self):
|
||||
"""The directory containing the ``setup.py`` file."""
|
||||
return self.stage.source_path
|
||||
|
||||
def python(self, *args, **kwargs):
|
||||
inspect.getmodule(self).python(*args, **kwargs)
|
||||
|
||||
def setup_py(self, *args, **kwargs):
|
||||
setup = self.setup_file()
|
||||
|
||||
with working_dir(self.build_directory):
|
||||
self.python(setup, '--no-user-cfg', *args, **kwargs)
|
||||
|
||||
def _setup_command_available(self, command):
|
||||
"""Determines whether or not a setup.py command exists.
|
||||
|
||||
Args:
|
||||
command (str): The command to look for
|
||||
|
||||
Returns:
|
||||
bool: True if the command is found, else False
|
||||
"""
|
||||
kwargs = {
|
||||
'output': os.devnull,
|
||||
'error': os.devnull,
|
||||
'fail_on_error': False
|
||||
}
|
||||
|
||||
python = inspect.getmodule(self).python
|
||||
setup = self.setup_file()
|
||||
|
||||
python(setup, '--no-user-cfg', command, '--help', **kwargs)
|
||||
return python.returncode == 0
|
||||
|
||||
# The following phases and their descriptions come from:
|
||||
# $ python setup.py --help-commands
|
||||
|
||||
# Standard commands
|
||||
|
||||
def build(self, spec, prefix):
|
||||
"""Build everything needed to install."""
|
||||
args = self.build_args(spec, prefix)
|
||||
|
||||
self.setup_py('build', *args)
|
||||
|
||||
def build_args(self, spec, prefix):
|
||||
"""Arguments to pass to build."""
|
||||
return []
|
||||
|
||||
def build_py(self, spec, prefix):
|
||||
'''"Build" pure Python modules (copy to build directory).'''
|
||||
args = self.build_py_args(spec, prefix)
|
||||
|
||||
self.setup_py('build_py', *args)
|
||||
|
||||
def build_py_args(self, spec, prefix):
|
||||
"""Arguments to pass to build_py."""
|
||||
return []
|
||||
|
||||
def build_ext(self, spec, prefix):
|
||||
"""Build C/C++ extensions (compile/link to build directory)."""
|
||||
args = self.build_ext_args(spec, prefix)
|
||||
|
||||
self.setup_py('build_ext', *args)
|
||||
|
||||
def build_ext_args(self, spec, prefix):
|
||||
"""Arguments to pass to build_ext."""
|
||||
return []
|
||||
|
||||
def build_clib(self, spec, prefix):
|
||||
"""Build C/C++ libraries used by Python extensions."""
|
||||
args = self.build_clib_args(spec, prefix)
|
||||
|
||||
self.setup_py('build_clib', *args)
|
||||
|
||||
def build_clib_args(self, spec, prefix):
|
||||
"""Arguments to pass to build_clib."""
|
||||
return []
|
||||
|
||||
def build_scripts(self, spec, prefix):
|
||||
'''"Build" scripts (copy and fixup #! line).'''
|
||||
args = self.build_scripts_args(spec, prefix)
|
||||
|
||||
self.setup_py('build_scripts', *args)
|
||||
|
||||
def clean(self, spec, prefix):
|
||||
"""Clean up temporary files from 'build' command."""
|
||||
args = self.clean_args(spec, prefix)
|
||||
|
||||
self.setup_py('clean', *args)
|
||||
|
||||
def clean_args(self, spec, prefix):
|
||||
"""Arguments to pass to clean."""
|
||||
return []
|
||||
|
||||
def install(self, spec, prefix):
|
||||
"""Install everything from build directory."""
|
||||
args = self.install_args(spec, prefix)
|
||||
|
||||
self.setup_py('install', *args)
|
||||
|
||||
def install_args(self, spec, prefix):
|
||||
"""Arguments to pass to install."""
|
||||
args = ['--prefix={0}'.format(prefix)]
|
||||
|
||||
# This option causes python packages (including setuptools) NOT
|
||||
# to create eggs or easy-install.pth files. Instead, they
|
||||
# install naturally into $prefix/pythonX.Y/site-packages.
|
||||
#
|
||||
# Eggs add an extra level of indirection to sys.path, slowing
|
||||
# down large HPC runs. They are also deprecated in favor of
|
||||
# wheels, which use a normal layout when installed.
|
||||
#
|
||||
# Spack manages the package directory on its own by symlinking
|
||||
# extensions into the site-packages directory, so we don't really
|
||||
# need the .pth files or egg directories, anyway.
|
||||
if ('py-setuptools' == spec.name or # this is setuptools, or
|
||||
'py-setuptools' in spec._dependencies): # it's an immediate dep
|
||||
args += ['--single-version-externally-managed', '--root=/']
|
||||
|
||||
return args
|
||||
|
||||
def install_lib(self, spec, prefix):
|
||||
"""Install all Python modules (extensions and pure Python)."""
|
||||
args = self.install_lib_args(spec, prefix)
|
||||
|
||||
self.setup_py('install_lib', *args)
|
||||
|
||||
def install_lib_args(self, spec, prefix):
|
||||
"""Arguments to pass to install_lib."""
|
||||
return []
|
||||
|
||||
def install_headers(self, spec, prefix):
|
||||
"""Install C/C++ header files."""
|
||||
args = self.install_headers_args(spec, prefix)
|
||||
|
||||
self.setup_py('install_headers', *args)
|
||||
|
||||
def install_headers_args(self, spec, prefix):
|
||||
"""Arguments to pass to install_headers."""
|
||||
return []
|
||||
|
||||
def install_scripts(self, spec, prefix):
|
||||
"""Install scripts (Python or otherwise)."""
|
||||
args = self.install_scripts_args(spec, prefix)
|
||||
|
||||
self.setup_py('install_scripts', *args)
|
||||
|
||||
def install_scripts_args(self, spec, prefix):
|
||||
"""Arguments to pass to install_scripts."""
|
||||
return []
|
||||
|
||||
def install_data(self, spec, prefix):
|
||||
"""Install data files."""
|
||||
args = self.install_data_args(spec, prefix)
|
||||
|
||||
self.setup_py('install_data', *args)
|
||||
|
||||
def install_data_args(self, spec, prefix):
|
||||
"""Arguments to pass to install_data."""
|
||||
return []
|
||||
|
||||
def sdist(self, spec, prefix):
|
||||
"""Create a source distribution (tarball, zip file, etc.)."""
|
||||
args = self.sdist_args(spec, prefix)
|
||||
|
||||
self.setup_py('sdist', *args)
|
||||
|
||||
def sdist_args(self, spec, prefix):
|
||||
"""Arguments to pass to sdist."""
|
||||
return []
|
||||
|
||||
def register(self, spec, prefix):
|
||||
"""Register the distribution with the Python package index."""
|
||||
args = self.register_args(spec, prefix)
|
||||
|
||||
self.setup_py('register', *args)
|
||||
|
||||
def register_args(self, spec, prefix):
|
||||
"""Arguments to pass to register."""
|
||||
return []
|
||||
|
||||
def bdist(self, spec, prefix):
|
||||
"""Create a built (binary) distribution."""
|
||||
args = self.bdist_args(spec, prefix)
|
||||
|
||||
self.setup_py('bdist', *args)
|
||||
|
||||
def bdist_args(self, spec, prefix):
|
||||
"""Arguments to pass to bdist."""
|
||||
return []
|
||||
|
||||
def bdist_dumb(self, spec, prefix):
|
||||
'''Create a "dumb" built distribution.'''
|
||||
args = self.bdist_dumb_args(spec, prefix)
|
||||
|
||||
self.setup_py('bdist_dumb', *args)
|
||||
|
||||
def bdist_dumb_args(self, spec, prefix):
|
||||
"""Arguments to pass to bdist_dumb."""
|
||||
return []
|
||||
|
||||
def bdist_rpm(self, spec, prefix):
|
||||
"""Create an RPM distribution."""
|
||||
args = self.bdist_rpm(spec, prefix)
|
||||
|
||||
self.setup_py('bdist_rpm', *args)
|
||||
|
||||
def bdist_rpm_args(self, spec, prefix):
|
||||
"""Arguments to pass to bdist_rpm."""
|
||||
return []
|
||||
|
||||
def bdist_wininst(self, spec, prefix):
|
||||
"""Create an executable installer for MS Windows."""
|
||||
args = self.bdist_wininst_args(spec, prefix)
|
||||
|
||||
self.setup_py('bdist_wininst', *args)
|
||||
|
||||
def bdist_wininst_args(self, spec, prefix):
|
||||
"""Arguments to pass to bdist_wininst."""
|
||||
return []
|
||||
|
||||
def upload(self, spec, prefix):
|
||||
"""Upload binary package to PyPI."""
|
||||
args = self.upload_args(spec, prefix)
|
||||
|
||||
self.setup_py('upload', *args)
|
||||
|
||||
def upload_args(self, spec, prefix):
|
||||
"""Arguments to pass to upload."""
|
||||
return []
|
||||
|
||||
def check(self, spec, prefix):
|
||||
"""Perform some checks on the package."""
|
||||
args = self.check_args(spec, prefix)
|
||||
|
||||
self.setup_py('check', *args)
|
||||
|
||||
def check_args(self, spec, prefix):
|
||||
"""Arguments to pass to check."""
|
||||
return []
|
||||
|
||||
# Testing
|
||||
|
||||
def test(self):
|
||||
"""Run unit tests after in-place build.
|
||||
|
||||
These tests are only run if the package actually has a 'test' command.
|
||||
"""
|
||||
if self._setup_command_available('test'):
|
||||
args = self.test_args(self.spec, self.prefix)
|
||||
|
||||
self.setup_py('test', *args)
|
||||
|
||||
def test_args(self, spec, prefix):
|
||||
"""Arguments to pass to test."""
|
||||
return []
|
||||
|
||||
run_after('build')(PackageBase._run_default_build_time_test_callbacks)
|
||||
|
||||
def import_module_test(self):
|
||||
"""Attempts to import the module that was just installed.
|
||||
|
||||
This test is only run if the package overrides
|
||||
:py:attr:`import_modules` with a list of module names."""
|
||||
|
||||
# Make sure we are importing the installed modules,
|
||||
# not the ones in the current directory
|
||||
with working_dir('..'):
|
||||
for module in self.import_modules:
|
||||
self.python('-c', 'import {0}'.format(module))
|
||||
|
||||
run_after('install')(PackageBase._run_default_install_time_test_callbacks)
|
||||
|
||||
# Check that self.prefix is there after installation
|
||||
run_after('install')(PackageBase.sanity_check_prefix)
|
Reference in New Issue
Block a user