Merge branch 'develop' into correct-cc
This commit is contained in:
commit
9017ec5865
@ -150,7 +150,7 @@ def main():
|
|||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
tty.die("Keyboard interrupt.")
|
tty.die("Keyboard interrupt.")
|
||||||
|
|
||||||
# Allow commands to return values if they want to exit with some ohter code.
|
# Allow commands to return values if they want to exit with some other code.
|
||||||
if return_val is None:
|
if return_val is None:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif isinstance(return_val, int):
|
elif isinstance(return_val, int):
|
||||||
|
@ -112,7 +112,7 @@ def partition_list(elements, predicate):
|
|||||||
|
|
||||||
def caller_locals():
|
def caller_locals():
|
||||||
"""This will return the locals of the *parent* of the caller.
|
"""This will return the locals of the *parent* of the caller.
|
||||||
This allows a fucntion to insert variables into its caller's
|
This allows a function to insert variables into its caller's
|
||||||
scope. Yes, this is some black magic, and yes it's useful
|
scope. Yes, this is some black magic, and yes it's useful
|
||||||
for implementing things like depends_on and provides.
|
for implementing things like depends_on and provides.
|
||||||
"""
|
"""
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import getpass
|
||||||
from llnl.util.filesystem import *
|
from llnl.util.filesystem import *
|
||||||
|
|
||||||
# This lives in $prefix/lib/spack/spack/__file__
|
# This lives in $prefix/lib/spack/spack/__file__
|
||||||
@ -111,9 +112,17 @@
|
|||||||
# that it can create.
|
# that it can create.
|
||||||
tmp_dirs = []
|
tmp_dirs = []
|
||||||
_default_tmp = tempfile.gettempdir()
|
_default_tmp = tempfile.gettempdir()
|
||||||
if _default_tmp != os.getcwd():
|
_tmp_user = getpass.getuser()
|
||||||
tmp_dirs.append(os.path.join(_default_tmp, 'spack-stage'))
|
|
||||||
tmp_dirs.append('/nfs/tmp2/%u/spack-stage')
|
_tmp_candidates = (_default_tmp, '/nfs/tmp2', '/tmp', '/var/tmp')
|
||||||
|
for path in _tmp_candidates:
|
||||||
|
# don't add a second username if it's already unique by user.
|
||||||
|
if not _tmp_user in path:
|
||||||
|
tmp_dirs.append(join_path(path, '%u', 'spack-stage'))
|
||||||
|
|
||||||
|
for path in _tmp_candidates:
|
||||||
|
if not path in tmp_dirs:
|
||||||
|
tmp_dirs.append(join_path(path, 'spack-stage'))
|
||||||
|
|
||||||
# Whether spack should allow installation of unsafe versions of
|
# Whether spack should allow installation of unsafe versions of
|
||||||
# software. "Unsafe" versions are ones it doesn't have a checksum
|
# software. "Unsafe" versions are ones it doesn't have a checksum
|
||||||
|
@ -145,7 +145,7 @@ def add_env_path(path):
|
|||||||
# Install root prefix
|
# Install root prefix
|
||||||
os.environ[SPACK_INSTALL] = spack.install_path
|
os.environ[SPACK_INSTALL] = spack.install_path
|
||||||
|
|
||||||
# Remove these vars from the environment during build becaus they
|
# Remove these vars from the environment during build because they
|
||||||
# can affect how some packages find libraries. We want to make
|
# can affect how some packages find libraries. We want to make
|
||||||
# sure that builds never pull in unintended external dependencies.
|
# sure that builds never pull in unintended external dependencies.
|
||||||
pop_keys(os.environ, "LD_LIBRARY_PATH", "LD_RUN_PATH", "DYLD_LIBRARY_PATH")
|
pop_keys(os.environ, "LD_LIBRARY_PATH", "LD_RUN_PATH", "DYLD_LIBRARY_PATH")
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
from spack.version import *
|
from spack.version import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DefaultConcretizer(object):
|
class DefaultConcretizer(object):
|
||||||
"""This class doesn't have any state, it just provides some methods for
|
"""This class doesn't have any state, it just provides some methods for
|
||||||
concretization. You can subclass it to override just some of the
|
concretization. You can subclass it to override just some of the
|
||||||
@ -68,9 +67,17 @@ def concretize_version(self, spec):
|
|||||||
# If there are known available versions, return the most recent
|
# If there are known available versions, return the most recent
|
||||||
# version that satisfies the spec
|
# version that satisfies the spec
|
||||||
pkg = spec.package
|
pkg = spec.package
|
||||||
|
|
||||||
|
# Key function to sort versions first by whether they were
|
||||||
|
# marked `preferred=True`, then by most recent.
|
||||||
|
def preferred_key(v):
|
||||||
|
prefer = pkg.versions[v].get('preferred', False)
|
||||||
|
return (prefer, v)
|
||||||
|
|
||||||
valid_versions = sorted(
|
valid_versions = sorted(
|
||||||
[v for v in pkg.versions
|
[v for v in pkg.versions
|
||||||
if any(v.satisfies(sv) for sv in spec.versions)])
|
if any(v.satisfies(sv) for sv in spec.versions)],
|
||||||
|
key=preferred_key)
|
||||||
|
|
||||||
if valid_versions:
|
if valid_versions:
|
||||||
spec.versions = ver([valid_versions[-1]])
|
spec.versions = ver([valid_versions[-1]])
|
||||||
|
@ -42,15 +42,19 @@ class OpenMpi(Package):
|
|||||||
* ``extends``
|
* ``extends``
|
||||||
* ``patch``
|
* ``patch``
|
||||||
* ``variant``
|
* ``variant``
|
||||||
|
* ``resource``
|
||||||
|
|
||||||
"""
|
"""
|
||||||
__all__ = [ 'depends_on', 'extends', 'provides', 'patch', 'version',
|
__all__ = ['depends_on', 'extends', 'provides', 'patch', 'version',
|
||||||
'variant' ]
|
'variant', 'resource']
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import inspect
|
import inspect
|
||||||
|
import os.path
|
||||||
|
import functools
|
||||||
|
|
||||||
from llnl.util.lang import *
|
from llnl.util.lang import *
|
||||||
|
from llnl.util.filesystem import join_path
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
import spack.spec
|
import spack.spec
|
||||||
@ -60,7 +64,8 @@ class OpenMpi(Package):
|
|||||||
from spack.patch import Patch
|
from spack.patch import Patch
|
||||||
from spack.variant import Variant
|
from spack.variant import Variant
|
||||||
from spack.spec import Spec, parse_anonymous_spec
|
from spack.spec import Spec, parse_anonymous_spec
|
||||||
|
from spack.resource import Resource
|
||||||
|
from spack.fetch_strategy import from_kwargs
|
||||||
|
|
||||||
#
|
#
|
||||||
# This is a list of all directives, built up as they are defined in
|
# This is a list of all directives, built up as they are defined in
|
||||||
@ -79,8 +84,8 @@ class directive(object):
|
|||||||
"""Decorator for Spack directives.
|
"""Decorator for Spack directives.
|
||||||
|
|
||||||
Spack directives allow you to modify a package while it is being
|
Spack directives allow you to modify a package while it is being
|
||||||
defined, e.g. to add version or depenency information. Directives
|
defined, e.g. to add version or dependency information. Directives
|
||||||
are one of the key pieces of Spack's package "langauge", which is
|
are one of the key pieces of Spack's package "language", which is
|
||||||
embedded in python.
|
embedded in python.
|
||||||
|
|
||||||
Here's an example directive:
|
Here's an example directive:
|
||||||
@ -141,6 +146,7 @@ def ensure_dicts(self, pkg):
|
|||||||
def __call__(self, directive_function):
|
def __call__(self, directive_function):
|
||||||
directives[directive_function.__name__] = self
|
directives[directive_function.__name__] = self
|
||||||
|
|
||||||
|
@functools.wraps(directive_function)
|
||||||
def wrapped(*args, **kwargs):
|
def wrapped(*args, **kwargs):
|
||||||
pkg = DictWrapper(caller_locals())
|
pkg = DictWrapper(caller_locals())
|
||||||
self.ensure_dicts(pkg)
|
self.ensure_dicts(pkg)
|
||||||
@ -259,6 +265,43 @@ def variant(pkg, name, default=False, description=""):
|
|||||||
pkg.variants[name] = Variant(default, description)
|
pkg.variants[name] = Variant(default, description)
|
||||||
|
|
||||||
|
|
||||||
|
@directive('resources')
|
||||||
|
def resource(pkg, **kwargs):
|
||||||
|
"""
|
||||||
|
Define an external resource to be fetched and staged when building the package. Based on the keywords present in the
|
||||||
|
dictionary the appropriate FetchStrategy will be used for the resource. Resources are fetched and staged in their
|
||||||
|
own folder inside spack stage area, and then linked into the stage area of the package that needs them.
|
||||||
|
|
||||||
|
List of recognized keywords:
|
||||||
|
|
||||||
|
* 'when' : (optional) represents the condition upon which the resource is needed
|
||||||
|
* 'destination' : (optional) path where to link the resource. This path must be relative to the main package stage
|
||||||
|
area.
|
||||||
|
* 'placement' : (optional) gives the possibility to fine tune how the resource is linked into the main package stage
|
||||||
|
area.
|
||||||
|
"""
|
||||||
|
when = kwargs.get('when', pkg.name)
|
||||||
|
destination = kwargs.get('destination', "")
|
||||||
|
placement = kwargs.get('placement', None)
|
||||||
|
# Check if the path is relative
|
||||||
|
if os.path.isabs(destination):
|
||||||
|
message = "The destination keyword of a resource directive can't be an absolute path.\n"
|
||||||
|
message += "\tdestination : '{dest}\n'".format(dest=destination)
|
||||||
|
raise RuntimeError(message)
|
||||||
|
# Check if the path falls within the main package stage area
|
||||||
|
test_path = 'stage_folder_root/'
|
||||||
|
normalized_destination = os.path.normpath(join_path(test_path, destination)) # Normalized absolute path
|
||||||
|
if test_path not in normalized_destination:
|
||||||
|
message = "The destination folder of a resource must fall within the main package stage directory.\n"
|
||||||
|
message += "\tdestination : '{dest}'\n".format(dest=destination)
|
||||||
|
raise RuntimeError(message)
|
||||||
|
when_spec = parse_anonymous_spec(when, pkg.name)
|
||||||
|
resources = pkg.resources.setdefault(when_spec, [])
|
||||||
|
fetcher = from_kwargs(**kwargs)
|
||||||
|
name = kwargs.get('name')
|
||||||
|
resources.append(Resource(name, fetcher, destination, placement))
|
||||||
|
|
||||||
|
|
||||||
class DirectiveError(spack.error.SpackError):
|
class DirectiveError(spack.error.SpackError):
|
||||||
"""This is raised when something is wrong with a package directive."""
|
"""This is raised when something is wrong with a package directive."""
|
||||||
def __init__(self, directive, message):
|
def __init__(self, directive, message):
|
||||||
|
@ -634,6 +634,22 @@ def from_url(url):
|
|||||||
return URLFetchStrategy(url)
|
return URLFetchStrategy(url)
|
||||||
|
|
||||||
|
|
||||||
|
def from_kwargs(**kwargs):
|
||||||
|
"""
|
||||||
|
Construct the appropriate FetchStrategy from the given keyword arguments.
|
||||||
|
|
||||||
|
:param kwargs: dictionary of keyword arguments
|
||||||
|
:return: fetcher or raise a FetchError exception
|
||||||
|
"""
|
||||||
|
for fetcher in all_strategies:
|
||||||
|
if fetcher.matches(kwargs):
|
||||||
|
return fetcher(**kwargs)
|
||||||
|
# Raise an error in case we can't instantiate any known strategy
|
||||||
|
message = "Cannot instantiate any FetchStrategy"
|
||||||
|
long_message = message + " from the given arguments : {arguments}".format(srguments=kwargs)
|
||||||
|
raise FetchError(message, long_message)
|
||||||
|
|
||||||
|
|
||||||
def args_are_for(args, fetcher):
|
def args_are_for(args, fetcher):
|
||||||
fetcher.matches(args)
|
fetcher.matches(args)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
This file contains code for creating spack mirror directories. A
|
This file contains code for creating spack mirror directories. A
|
||||||
mirror is an organized hierarchy containing specially named archive
|
mirror is an organized hierarchy containing specially named archive
|
||||||
files. This enabled spack to know where to find files in a mirror if
|
files. This enabled spack to know where to find files in a mirror if
|
||||||
the main server for a particualr package is down. Or, if the computer
|
the main server for a particular package is down. Or, if the computer
|
||||||
where spack is run is not connected to the internet, it allows spack
|
where spack is run is not connected to the internet, it allows spack
|
||||||
to download packages directly from a mirror (e.g., on an intranet).
|
to download packages directly from a mirror (e.g., on an intranet).
|
||||||
"""
|
"""
|
||||||
@ -42,7 +42,7 @@
|
|||||||
from spack.spec import Spec
|
from spack.spec import Spec
|
||||||
from spack.stage import Stage
|
from spack.stage import Stage
|
||||||
from spack.version import *
|
from spack.version import *
|
||||||
from spack.util.compression import extension
|
from spack.util.compression import extension, allowed_archive
|
||||||
|
|
||||||
|
|
||||||
def mirror_archive_filename(spec):
|
def mirror_archive_filename(spec):
|
||||||
@ -87,11 +87,26 @@ def get_matching_versions(specs, **kwargs):
|
|||||||
if v.satisfies(spec.versions):
|
if v.satisfies(spec.versions):
|
||||||
s = Spec(pkg.name)
|
s = Spec(pkg.name)
|
||||||
s.versions = VersionList([v])
|
s.versions = VersionList([v])
|
||||||
|
s.variants = spec.variants.copy()
|
||||||
matching.append(s)
|
matching.append(s)
|
||||||
|
|
||||||
return matching
|
return matching
|
||||||
|
|
||||||
|
|
||||||
|
def suggest_archive_basename(resource):
|
||||||
|
"""
|
||||||
|
Return a tentative basename for an archive. Raise an exception if the name is among the allowed archive types.
|
||||||
|
|
||||||
|
:param fetcher:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
basename = os.path.basename(resource.fetcher.url)
|
||||||
|
if not allowed_archive(basename):
|
||||||
|
raise RuntimeError("%s is not an allowed archive tye" % basename)
|
||||||
|
return basename
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create(path, specs, **kwargs):
|
def create(path, specs, **kwargs):
|
||||||
"""Create a directory to be used as a spack mirror, and fill it with
|
"""Create a directory to be used as a spack mirror, and fill it with
|
||||||
package archives.
|
package archives.
|
||||||
@ -108,7 +123,7 @@ def create(path, specs, **kwargs):
|
|||||||
|
|
||||||
Return Value:
|
Return Value:
|
||||||
Returns a tuple of lists: (present, mirrored, error)
|
Returns a tuple of lists: (present, mirrored, error)
|
||||||
* present: Package specs that were already prsent.
|
* present: Package specs that were already present.
|
||||||
* mirrored: Package specs that were successfully mirrored.
|
* mirrored: Package specs that were successfully mirrored.
|
||||||
* error: Package specs that failed to mirror due to some error.
|
* error: Package specs that failed to mirror due to some error.
|
||||||
|
|
||||||
@ -140,6 +155,7 @@ def create(path, specs, **kwargs):
|
|||||||
error = []
|
error = []
|
||||||
|
|
||||||
# Iterate through packages and download all the safe tarballs for each of them
|
# Iterate through packages and download all the safe tarballs for each of them
|
||||||
|
everything_already_exists = True
|
||||||
for spec in version_specs:
|
for spec in version_specs:
|
||||||
pkg = spec.package
|
pkg = spec.package
|
||||||
|
|
||||||
@ -152,26 +168,47 @@ def create(path, specs, **kwargs):
|
|||||||
|
|
||||||
if os.path.exists(archive_path):
|
if os.path.exists(archive_path):
|
||||||
tty.msg("Already added %s" % spec.format("$_$@"))
|
tty.msg("Already added %s" % spec.format("$_$@"))
|
||||||
|
else:
|
||||||
|
everything_already_exists = False
|
||||||
|
# Set up a stage and a fetcher for the download
|
||||||
|
unique_fetch_name = spec.format("$_$@")
|
||||||
|
fetcher = fs.for_package_version(pkg, pkg.version)
|
||||||
|
stage = Stage(fetcher, name=unique_fetch_name)
|
||||||
|
fetcher.set_stage(stage)
|
||||||
|
|
||||||
|
# Do the fetch and checksum if necessary
|
||||||
|
fetcher.fetch()
|
||||||
|
if not kwargs.get('no_checksum', False):
|
||||||
|
fetcher.check()
|
||||||
|
tty.msg("Checksum passed for %s@%s" % (pkg.name, pkg.version))
|
||||||
|
|
||||||
|
# Fetchers have to know how to archive their files. Use
|
||||||
|
# that to move/copy/create an archive in the mirror.
|
||||||
|
fetcher.archive(archive_path)
|
||||||
|
tty.msg("Added %s." % spec.format("$_$@"))
|
||||||
|
|
||||||
|
# Fetch resources if they are associated with the spec
|
||||||
|
resources = pkg._get_resources()
|
||||||
|
for resource in resources:
|
||||||
|
resource_archive_path = join_path(subdir, suggest_archive_basename(resource))
|
||||||
|
if os.path.exists(resource_archive_path):
|
||||||
|
tty.msg("Already added resource %s (%s@%s)." % (resource.name, pkg.name, pkg.version))
|
||||||
|
continue
|
||||||
|
everything_already_exists = False
|
||||||
|
resource_stage_folder = pkg._resource_stage(resource)
|
||||||
|
resource_stage = Stage(resource.fetcher, name=resource_stage_folder)
|
||||||
|
resource.fetcher.set_stage(resource_stage)
|
||||||
|
resource.fetcher.fetch()
|
||||||
|
if not kwargs.get('no_checksum', False):
|
||||||
|
resource.fetcher.check()
|
||||||
|
tty.msg("Checksum passed for the resource %s (%s@%s)" % (resource.name, pkg.name, pkg.version))
|
||||||
|
resource.fetcher.archive(resource_archive_path)
|
||||||
|
tty.msg("Added resource %s (%s@%s)." % (resource.name, pkg.name, pkg.version))
|
||||||
|
|
||||||
|
if everything_already_exists:
|
||||||
present.append(spec)
|
present.append(spec)
|
||||||
continue
|
else:
|
||||||
|
mirrored.append(spec)
|
||||||
# Set up a stage and a fetcher for the download
|
|
||||||
unique_fetch_name = spec.format("$_$@")
|
|
||||||
fetcher = fs.for_package_version(pkg, pkg.version)
|
|
||||||
stage = Stage(fetcher, name=unique_fetch_name)
|
|
||||||
fetcher.set_stage(stage)
|
|
||||||
|
|
||||||
# Do the fetch and checksum if necessary
|
|
||||||
fetcher.fetch()
|
|
||||||
if not kwargs.get('no_checksum', False):
|
|
||||||
fetcher.check()
|
|
||||||
tty.msg("Checksum passed for %s@%s" % (pkg.name, pkg.version))
|
|
||||||
|
|
||||||
# Fetchers have to know how to archive their files. Use
|
|
||||||
# that to move/copy/create an archive in the mirror.
|
|
||||||
fetcher.archive(archive_path)
|
|
||||||
tty.msg("Added %s." % spec.format("$_$@"))
|
|
||||||
mirrored.append(spec)
|
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if spack.debug:
|
if spack.debug:
|
||||||
|
@ -655,26 +655,62 @@ def do_fetch(self):
|
|||||||
"Will not fetch %s." % self.spec.format('$_$@'), checksum_msg)
|
"Will not fetch %s." % self.spec.format('$_$@'), checksum_msg)
|
||||||
|
|
||||||
self.stage.fetch()
|
self.stage.fetch()
|
||||||
|
|
||||||
|
##########
|
||||||
|
# Fetch resources
|
||||||
|
resources = self._get_resources()
|
||||||
|
for resource in resources:
|
||||||
|
resource_stage_folder = self._resource_stage(resource)
|
||||||
|
# FIXME : works only for URLFetchStrategy
|
||||||
|
resource_mirror = join_path(self.name, os.path.basename(resource.fetcher.url))
|
||||||
|
resource_stage = Stage(resource.fetcher, name=resource_stage_folder, mirror_path=resource_mirror)
|
||||||
|
resource.fetcher.set_stage(resource_stage)
|
||||||
|
# Delegate to stage object to trigger mirror logic
|
||||||
|
resource_stage.fetch()
|
||||||
|
resource_stage.check()
|
||||||
|
##########
|
||||||
|
|
||||||
self._fetch_time = time.time() - start_time
|
self._fetch_time = time.time() - start_time
|
||||||
|
|
||||||
if spack.do_checksum and self.version in self.versions:
|
if spack.do_checksum and self.version in self.versions:
|
||||||
self.stage.check()
|
self.stage.check()
|
||||||
|
|
||||||
|
|
||||||
def do_stage(self):
|
def do_stage(self):
|
||||||
"""Unpacks the fetched tarball, then changes into the expanded tarball
|
"""Unpacks the fetched tarball, then changes into the expanded tarball
|
||||||
directory."""
|
directory."""
|
||||||
if not self.spec.concrete:
|
if not self.spec.concrete:
|
||||||
raise ValueError("Can only stage concrete packages.")
|
raise ValueError("Can only stage concrete packages.")
|
||||||
|
|
||||||
self.do_fetch()
|
def _expand_archive(stage, name=self.name):
|
||||||
|
archive_dir = stage.source_path
|
||||||
|
if not archive_dir:
|
||||||
|
stage.expand_archive()
|
||||||
|
tty.msg("Created stage in %s." % stage.path)
|
||||||
|
else:
|
||||||
|
tty.msg("Already staged %s in %s." % (name, stage.path))
|
||||||
|
|
||||||
archive_dir = self.stage.source_path
|
|
||||||
if not archive_dir:
|
self.do_fetch()
|
||||||
self.stage.expand_archive()
|
_expand_archive(self.stage)
|
||||||
tty.msg("Created stage in %s." % self.stage.path)
|
|
||||||
else:
|
##########
|
||||||
tty.msg("Already staged %s in %s." % (self.name, self.stage.path))
|
# Stage resources in appropriate path
|
||||||
|
resources = self._get_resources()
|
||||||
|
for resource in resources:
|
||||||
|
stage = resource.fetcher.stage
|
||||||
|
_expand_archive(stage, resource.name)
|
||||||
|
# Turn placement into a dict with relative paths
|
||||||
|
placement = os.path.basename(stage.source_path) if resource.placement is None else resource.placement
|
||||||
|
if not isinstance(placement, dict):
|
||||||
|
placement = {'': placement}
|
||||||
|
# Make the paths in the dictionary absolute and link
|
||||||
|
for key, value in placement.iteritems():
|
||||||
|
link_path = join_path(self.stage.source_path, resource.destination, value)
|
||||||
|
source_path = join_path(stage.source_path, key)
|
||||||
|
if not os.path.exists(link_path):
|
||||||
|
# Create a symlink
|
||||||
|
os.symlink(source_path, link_path)
|
||||||
|
##########
|
||||||
self.stage.chdir_to_source()
|
self.stage.chdir_to_source()
|
||||||
|
|
||||||
|
|
||||||
@ -746,6 +782,19 @@ def do_fake_install(self):
|
|||||||
mkdirp(self.prefix.man1)
|
mkdirp(self.prefix.man1)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_resources(self):
|
||||||
|
resources = []
|
||||||
|
# Select the resources that are needed for this build
|
||||||
|
for when_spec, resource_list in self.resources.items():
|
||||||
|
if when_spec in self.spec:
|
||||||
|
resources.extend(resource_list)
|
||||||
|
return resources
|
||||||
|
|
||||||
|
def _resource_stage(self, resource):
|
||||||
|
pieces = ['resource', resource.name, self.spec.dag_hash()]
|
||||||
|
resource_stage_folder = '-'.join(pieces)
|
||||||
|
return resource_stage_folder
|
||||||
|
|
||||||
def _build_logger(self, log_path):
|
def _build_logger(self, log_path):
|
||||||
"""Create a context manager to log build output."""
|
"""Create a context manager to log build output."""
|
||||||
|
|
||||||
|
39
lib/spack/spack/resource.py
Normal file
39
lib/spack/spack/resource.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
##############################################################################
|
||||||
|
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
|
||||||
|
# Produced at the Lawrence Livermore National Laboratory.
|
||||||
|
#
|
||||||
|
# This file is part of Spack.
|
||||||
|
# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||||
|
# LLNL-CODE-647188
|
||||||
|
#
|
||||||
|
# For details, see https://scalability-llnl.github.io/spack
|
||||||
|
# Please also see the LICENSE file 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 General Public License (as published by
|
||||||
|
# the Free Software Foundation) version 2.1 dated 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 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
|
||||||
|
##############################################################################
|
||||||
|
"""
|
||||||
|
Describes an optional resource needed for a build. Typically a bunch of sources that can be built in-tree within another
|
||||||
|
package to enable optional features.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class Resource(object):
|
||||||
|
"""
|
||||||
|
Represents an optional resource. Aggregates a name, a fetcher, a destination and a placement
|
||||||
|
"""
|
||||||
|
def __init__(self, name, fetcher, destination, placement):
|
||||||
|
self.name = name
|
||||||
|
self.fetcher = fetcher
|
||||||
|
self.destination = destination
|
||||||
|
self.placement = placement
|
@ -22,8 +22,13 @@
|
|||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
from spack import *
|
from spack import *
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
class Clang(Package):
|
class Clang(Package):
|
||||||
"""The goal of the Clang project is to create a new C, C++,
|
"""The goal of the Clang project is to create a new C, C++,
|
||||||
Objective C and Objective C++ front-end for the LLVM compiler.
|
Objective C and Objective C++ front-end for the LLVM compiler.
|
||||||
@ -39,13 +44,52 @@ class Clang(Package):
|
|||||||
version('3.6.2', 'ff862793682f714bb7862325b9c06e20', url='http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz')
|
version('3.6.2', 'ff862793682f714bb7862325b9c06e20', url='http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz')
|
||||||
version('3.5.1', '93f9532f8f7e6f1d8e5c1116907051cb', url='http://llvm.org/releases/3.5.1/cfe-3.5.1.src.tar.xz')
|
version('3.5.1', '93f9532f8f7e6f1d8e5c1116907051cb', url='http://llvm.org/releases/3.5.1/cfe-3.5.1.src.tar.xz')
|
||||||
|
|
||||||
|
##########
|
||||||
|
# @3.7.0
|
||||||
|
resource(name='clang-tools-extra',
|
||||||
|
url='http://llvm.org/releases/3.7.0/clang-tools-extra-3.7.0.src.tar.xz',
|
||||||
|
md5='d5a87dacb65d981a427a536f6964642e', destination='tools', when='@3.7.0')
|
||||||
|
##########
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||||
|
|
||||||
with working_dir('spack-build', create=True):
|
with working_dir('spack-build', create=True):
|
||||||
|
|
||||||
|
options = []
|
||||||
|
if '@3.7.0:' in spec:
|
||||||
|
options.append('-DCLANG_DEFAULT_OPENMP_RUNTIME:STRING=libomp')
|
||||||
|
options.extend(std_cmake_args)
|
||||||
|
|
||||||
cmake('..',
|
cmake('..',
|
||||||
'-DCLANG_PATH_TO_LLVM_BUILD=%s' % spec['llvm'].prefix,
|
'-DCLANG_PATH_TO_LLVM_BUILD:PATH=%s' % spec['llvm'].prefix,
|
||||||
'-DLLVM_MAIN_SRC_DIR=%s' % spec['llvm'].prefix,
|
'-DLLVM_MAIN_SRC_DIR:PATH=%s' % spec['llvm'].prefix,
|
||||||
*std_cmake_args)
|
*options)
|
||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
|
# CLang doesn't look in llvm folders for system headers...
|
||||||
|
self.link_llvm_directories(spec)
|
||||||
|
|
||||||
|
def link_llvm_directories(self, spec):
|
||||||
|
|
||||||
|
def clang_include_dir_at(root):
|
||||||
|
return join_path(root, 'include')
|
||||||
|
|
||||||
|
def clang_lib_dir_at(root):
|
||||||
|
return join_path(root, 'lib/clang/', str(self.version), 'include')
|
||||||
|
|
||||||
|
def do_link(source_dir, destination_dir):
|
||||||
|
if os.path.exists(source_dir):
|
||||||
|
for name in os.listdir(source_dir):
|
||||||
|
source = join_path(source_dir, name)
|
||||||
|
link = join_path(destination_dir, name)
|
||||||
|
os.symlink(source, link)
|
||||||
|
|
||||||
|
# Link folder and files in include
|
||||||
|
llvm_dir = clang_include_dir_at(spec['llvm'].prefix)
|
||||||
|
clang_dir = clang_include_dir_at(self.prefix)
|
||||||
|
do_link(llvm_dir, clang_dir)
|
||||||
|
# Link folder and files in lib
|
||||||
|
llvm_dir = clang_lib_dir_at(spec['llvm'].prefix)
|
||||||
|
clang_dir = clang_lib_dir_at(self.prefix)
|
||||||
|
do_link(llvm_dir, clang_dir)
|
@ -26,16 +26,14 @@ def install(self, spec, prefix):
|
|||||||
if '+mpi' in spec:
|
if '+mpi' in spec:
|
||||||
extra_args.extend([
|
extra_args.extend([
|
||||||
"--enable-parallel",
|
"--enable-parallel",
|
||||||
"CC=%s" % spec['mpich'].prefix.bin + "/mpicc",
|
"CC=%s" % spec['mpi'].prefix.bin + "/mpicc",
|
||||||
"CXX=%s" % spec['mpich'].prefix.bin + "/mpic++",
|
"CXX=%s" % spec['mpi'].prefix.bin + "/mpic++",
|
||||||
])
|
])
|
||||||
|
|
||||||
configure(
|
configure(
|
||||||
"--prefix=%s" % prefix,
|
"--prefix=%s" % prefix,
|
||||||
"--with-zlib=%s" % spec['zlib'].prefix,
|
"--with-zlib=%s" % spec['zlib'].prefix,
|
||||||
"--enable-shared",
|
"--enable-shared",
|
||||||
"CC=%s" % spec['mpi'].prefix.bin + "/mpicc",
|
|
||||||
"CXX=%s" % spec['mpi'].prefix.bin + "/mpic++",
|
|
||||||
*extra_args)
|
*extra_args)
|
||||||
|
|
||||||
make()
|
make()
|
||||||
|
@ -42,13 +42,31 @@ class Llvm(Package):
|
|||||||
|
|
||||||
depends_on('python@2.7:')
|
depends_on('python@2.7:')
|
||||||
|
|
||||||
|
variant('libcxx', default=False, description="Builds the LLVM Standard C++ library targeting C++11")
|
||||||
|
|
||||||
|
##########
|
||||||
|
# @3.7.0
|
||||||
|
resource(name='compiler-rt',
|
||||||
|
url='http://llvm.org/releases/3.7.0/compiler-rt-3.7.0.src.tar.xz', md5='383c10affd513026f08936b5525523f5',
|
||||||
|
destination='projects', when='@3.7.0')
|
||||||
|
resource(name='openmp',
|
||||||
|
url='http://llvm.org/releases/3.7.0/openmp-3.7.0.src.tar.xz', md5='f482c86fdead50ba246a1a2b0bbf206f',
|
||||||
|
destination='projects', when='@3.7.0')
|
||||||
|
resource(name='libcxx',
|
||||||
|
url='http://llvm.org/releases/3.7.0/libcxx-3.7.0.src.tar.xz', md5='46aa5175cbe1ad42d6e9c995968e56dd',
|
||||||
|
destination='projects', placement='libcxx', when='+libcxx@3.7.0')
|
||||||
|
resource(name='libcxxabi',
|
||||||
|
url='http://llvm.org/releases/3.7.0/libcxxabi-3.7.0.src.tar.xz', md5='5aa769e2fca79fa5335cfae8f6258772',
|
||||||
|
destination='projects', placement='libcxxabi', when='+libcxx@3.7.0')
|
||||||
|
##########
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||||
|
|
||||||
with working_dir('spack-build', create=True):
|
with working_dir('spack-build', create=True):
|
||||||
cmake('..',
|
cmake('..',
|
||||||
'-DLLVM_REQUIRES_RTTI=1',
|
'-DLLVM_REQUIRES_RTTI:BOOL=ON',
|
||||||
'-DPYTHON_EXECUTABLE=%s/bin/python' % spec['python'].prefix,
|
'-DPYTHON_EXECUTABLE:PATH=%s/bin/python' % spec['python'].prefix,
|
||||||
*std_cmake_args)
|
*std_cmake_args)
|
||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
|
@ -13,13 +13,6 @@ class PyNumpy(Package):
|
|||||||
depends_on('netlib-blas+fpic')
|
depends_on('netlib-blas+fpic')
|
||||||
depends_on('netlib-lapack+shared')
|
depends_on('netlib-lapack+shared')
|
||||||
|
|
||||||
def patch(self):
|
|
||||||
filter_file(
|
|
||||||
"possible_executables = \['(gfortran|g77|ifort|efl)",
|
|
||||||
"possible_executables = ['fc",
|
|
||||||
"numpy/distutils/fcompiler/gnu.py",
|
|
||||||
"numpy/distutils/fcompiler/intel.py")
|
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
with open('site.cfg', 'w') as f:
|
with open('site.cfg', 'w') as f:
|
||||||
f.write('[DEFAULT]\n')
|
f.write('[DEFAULT]\n')
|
||||||
|
@ -17,7 +17,9 @@ class Python(Package):
|
|||||||
|
|
||||||
version('2.7.8', 'd235bdfa75b8396942e360a70487ee00')
|
version('2.7.8', 'd235bdfa75b8396942e360a70487ee00')
|
||||||
version('2.7.10', 'c685ef0b8e9f27b5e3db5db12b268ac6')
|
version('2.7.10', 'c685ef0b8e9f27b5e3db5db12b268ac6')
|
||||||
|
version('2.7.11', '1dbcc848b4cd8399a8199d000f9f823c', preferred=True)
|
||||||
version('3.5.0', 'd149d2812f10cbe04c042232e7964171')
|
version('3.5.0', 'd149d2812f10cbe04c042232e7964171')
|
||||||
|
version('3.5.1', 'e9ea6f2623fffcdd871b7b19113fde80')
|
||||||
|
|
||||||
depends_on("openssl")
|
depends_on("openssl")
|
||||||
depends_on("bzip2")
|
depends_on("bzip2")
|
||||||
@ -33,7 +35,8 @@ def install(self, spec, prefix):
|
|||||||
|
|
||||||
# Rest of install is pretty standard except setup.py needs to be able to read the CPPFLAGS
|
# Rest of install is pretty standard except setup.py needs to be able to read the CPPFLAGS
|
||||||
# and LDFLAGS as it scans for the library and headers to build
|
# and LDFLAGS as it scans for the library and headers to build
|
||||||
configure("--prefix=%s" % prefix,
|
configure_args= [
|
||||||
|
"--prefix=%s" % prefix,
|
||||||
"--with-threads",
|
"--with-threads",
|
||||||
"--enable-shared",
|
"--enable-shared",
|
||||||
"CPPFLAGS=-I%s/include -I%s/include -I%s/include -I%s/include -I%s/include -I%s/include" % (
|
"CPPFLAGS=-I%s/include -I%s/include -I%s/include -I%s/include -I%s/include -I%s/include" % (
|
||||||
@ -43,7 +46,11 @@ def install(self, spec, prefix):
|
|||||||
"LDFLAGS=-L%s/lib -L%s/lib -L%s/lib -L%s/lib -L%s/lib -L%s/lib" % (
|
"LDFLAGS=-L%s/lib -L%s/lib -L%s/lib -L%s/lib -L%s/lib -L%s/lib" % (
|
||||||
spec['openssl'].prefix, spec['bzip2'].prefix,
|
spec['openssl'].prefix, spec['bzip2'].prefix,
|
||||||
spec['readline'].prefix, spec['ncurses'].prefix,
|
spec['readline'].prefix, spec['ncurses'].prefix,
|
||||||
spec['sqlite'].prefix, spec['zlib'].prefix))
|
spec['sqlite'].prefix, spec['zlib'].prefix)
|
||||||
|
]
|
||||||
|
if spec.satisfies('@3:'):
|
||||||
|
configure_args.append('--without-ensurepip')
|
||||||
|
configure(*configure_args)
|
||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
|
|
||||||
@ -110,7 +117,7 @@ def python_ignore(self, ext_pkg, args):
|
|||||||
|
|
||||||
# Ignore pieces of setuptools installed by other packages.
|
# Ignore pieces of setuptools installed by other packages.
|
||||||
if ext_pkg.name != 'py-setuptools':
|
if ext_pkg.name != 'py-setuptools':
|
||||||
patterns.append(r'/site\.pyc?$')
|
patterns.append(r'/site[^/]*\.pyc?$')
|
||||||
patterns.append(r'setuptools\.pth')
|
patterns.append(r'setuptools\.pth')
|
||||||
patterns.append(r'bin/easy_install[^/]*$')
|
patterns.append(r'bin/easy_install[^/]*$')
|
||||||
patterns.append(r'setuptools.*egg$')
|
patterns.append(r'setuptools.*egg$')
|
||||||
|
55
var/spack/packages/valgrind/package.py
Normal file
55
var/spack/packages/valgrind/package.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
##############################################################################
|
||||||
|
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
|
||||||
|
# Produced at the Lawrence Livermore National Laboratory.
|
||||||
|
#
|
||||||
|
# This file is part of Spack.
|
||||||
|
# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||||
|
# LLNL-CODE-647188
|
||||||
|
#
|
||||||
|
# For details, see https://github.com/llnl/spack
|
||||||
|
# Please also see the LICENSE file 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 General Public License (as published by
|
||||||
|
# the Free Software Foundation) version 2.1 dated 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 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 Valgrind(Package):
|
||||||
|
"""
|
||||||
|
Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can
|
||||||
|
automatically detect many memory management and threading bugs, and profile your programs in detail. You can also
|
||||||
|
use Valgrind to build new tools.
|
||||||
|
|
||||||
|
Valgrind is Open Source / Free Software, and is freely available under the GNU General Public License, version 2.
|
||||||
|
"""
|
||||||
|
homepage = "http://valgrind.org/"
|
||||||
|
url = "http://valgrind.org/downloads/valgrind-3.11.0.tar.bz2"
|
||||||
|
|
||||||
|
version('3.11.0', '4ea62074da73ae82e0162d6550d3f129')
|
||||||
|
version('3.10.1', '60ddae962bc79e7c95cfc4667245707f')
|
||||||
|
version('3.10.0', '7c311a72a20388aceced1aa5573ce970')
|
||||||
|
|
||||||
|
variant('mpi', default=True, description='Activates MPI support for valgrind')
|
||||||
|
variant('boost', default=True, description='Activates boost support for valgrind')
|
||||||
|
|
||||||
|
depends_on('mpi', when='+mpi')
|
||||||
|
depends_on('boost', when='+boost')
|
||||||
|
|
||||||
|
def install(self, spec, prefix):
|
||||||
|
options = ['--prefix=%s' % prefix,
|
||||||
|
'--enable-ubsan']
|
||||||
|
configure(*options)
|
||||||
|
make()
|
||||||
|
make("install")
|
Loading…
Reference in New Issue
Block a user