From 076cc764a78c387d0e0cc38047a9df8497416f90 Mon Sep 17 00:00:00 2001 From: Ben Morgan Date: Fri, 18 Mar 2016 11:26:22 +0000 Subject: Add additional suffixes for GCC compiler --- lib/spack/spack/compilers/gcc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py index 495b638a3a..64214db32d 100644 --- a/lib/spack/spack/compilers/gcc.py +++ b/lib/spack/spack/compilers/gcc.py @@ -40,7 +40,8 @@ class Gcc(Compiler): fc_names = ['gfortran'] # MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes. - suffixes = [r'-mp-\d\.\d'] + # Homebrew and Linuxes may build gcc with -X, -X.Y suffixes + suffixes = [r'-mp-\d\.\d', r'-\d\.\d', r'-\d'] # Named wrapper links within spack.build_env_path link_paths = {'cc' : 'gcc/gcc', -- cgit v1.2.3-60-g2f50 From 1fa38689d87480bb0d291af9b9cf0dbcf7557eb5 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 18 Mar 2016 09:35:56 -0700 Subject: Created flatten_dependencies function that dummy packages can use to create sane install environments. --- lib/spack/spack/directory_layout.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index 242eb1afa0..9f17404062 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -33,6 +33,7 @@ import yaml import llnl.util.tty as tty from llnl.util.filesystem import join_path, mkdirp +from llnl.util.link_tree import * from spack.spec import Spec from spack.error import SpackError @@ -131,6 +132,23 @@ class DirectoryLayout(object): raise NotImplementedError() + def flatten_dependencies(self, spec, flat_dir): + """Make each dependency of spec present in dir via symlink.""" + for dep in spec.traverse(root=False): + name = dep.name + + dep_path = self.path_for_spec(dep) + dep_files = LinkTree(dep_path) + + os.mkdir(flat_dir+'/'+name) + + conflict = dep_files.find_conflict(flat_dir+'/'+name) + if conflict: + raise DependencyConflictError(conflict) + + dep_files.merge(flat_dir+'/'+name) + + def path_for_spec(self, spec): """Return an absolute path from the root to a directory for the spec.""" _check_concrete(spec) -- cgit v1.2.3-60-g2f50 From 80495e50f9b3a5de6d0aadb054a770a685939e79 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 18 Mar 2016 09:46:18 -0700 Subject: added error class for error that should never come up --- lib/spack/spack/directory_layout.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index 9f17404062..dfd0dc42e4 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -498,3 +498,10 @@ class NoSuchExtensionError(DirectoryLayoutError): super(NoSuchExtensionError, self).__init__( "%s cannot be removed from %s because it's not activated."% ( ext_spec.short_spec, spec.short_spec)) + +class DependencyConflictError(SpackError): + """Raised when the dependencies cannot be flattened as asked for.""" + def __init__(self, conflict): + super(DependencyConflictError, self).__init__( + "%s conflicts with another file in the flattened directory." %( + conflict)) -- cgit v1.2.3-60-g2f50 From 6acb830263e663b57bc8c077b348c897b0d1f612 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 18 Mar 2016 13:03:55 -0500 Subject: Add support for .tar files --- lib/spack/spack/url.py | 2 +- lib/spack/spack/util/compression.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py index ad551a6ded..f51f05cad7 100644 --- a/lib/spack/spack/url.py +++ b/lib/spack/spack/url.py @@ -142,7 +142,7 @@ def split_url_extension(path): def downloaded_file_extension(path): """This returns the type of archive a URL refers to. This is - sometimes confusing becasue of URLs like: + sometimes confusing because of URLs like: (1) https://github.com/petdance/ack/tarball/1.93_02 diff --git a/lib/spack/spack/util/compression.py b/lib/spack/spack/util/compression.py index ea1f233bce..5ae5867428 100644 --- a/lib/spack/spack/util/compression.py +++ b/lib/spack/spack/util/compression.py @@ -27,13 +27,12 @@ import os from itertools import product from spack.util.executable import which -# Supported archvie extensions. +# Supported archive extensions. PRE_EXTS = ["tar"] EXTS = ["gz", "bz2", "xz", "Z", "zip", "tgz"] -# Add EXTS last so that .tar.gz is matched *before* tar.gz -ALLOWED_ARCHIVE_TYPES = [".".join(l) for l in product(PRE_EXTS, EXTS)] + EXTS - +# Add PRE_EXTS and EXTS last so that .tar.gz is matched *before* .tar or .gz +ALLOWED_ARCHIVE_TYPES = [".".join(l) for l in product(PRE_EXTS, EXTS)] + PRE_EXTS + EXTS def allowed_archive(path): return any(path.endswith(t) for t in ALLOWED_ARCHIVE_TYPES) -- cgit v1.2.3-60-g2f50 From 76672a4e34e37aec0223e67d140fd19e9115b5a6 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 18 Mar 2016 11:28:44 -0700 Subject: Refactoring flat_install --- lib/spack/spack/__init__.py | 3 +++ lib/spack/spack/directory_layout.py | 24 ------------------------ lib/spack/spack/package.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index ab78ecef30..155e190597 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -174,3 +174,6 @@ __all__ += spack.directives.__all__ import spack.util.executable from spack.util.executable import * __all__ += spack.util.executable.__all__ + +from spack.package import flat_install, flatten_dependencies, DependencyConflictError +__all__ += ['flat_install', 'flatten_dependencies', 'DependencyConflictError'] diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index dfd0dc42e4..e275031387 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -132,23 +132,6 @@ class DirectoryLayout(object): raise NotImplementedError() - def flatten_dependencies(self, spec, flat_dir): - """Make each dependency of spec present in dir via symlink.""" - for dep in spec.traverse(root=False): - name = dep.name - - dep_path = self.path_for_spec(dep) - dep_files = LinkTree(dep_path) - - os.mkdir(flat_dir+'/'+name) - - conflict = dep_files.find_conflict(flat_dir+'/'+name) - if conflict: - raise DependencyConflictError(conflict) - - dep_files.merge(flat_dir+'/'+name) - - def path_for_spec(self, spec): """Return an absolute path from the root to a directory for the spec.""" _check_concrete(spec) @@ -498,10 +481,3 @@ class NoSuchExtensionError(DirectoryLayoutError): super(NoSuchExtensionError, self).__init__( "%s cannot be removed from %s because it's not activated."% ( ext_spec.short_spec, spec.short_spec)) - -class DependencyConflictError(SpackError): - """Raised when the dependencies cannot be flattened as asked for.""" - def __init__(self, conflict): - super(DependencyConflictError, self).__init__( - "%s conflicts with another file in the flattened directory." %( - conflict)) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 972a0410b9..1a962268cf 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1211,6 +1211,28 @@ class Package(object): return " ".join("-Wl,-rpath,%s" % p for p in self.rpath) +def flat_install(pkg, spec, prefix): + """Execute a dummy install and flatten dependencies""" + os.mkdir(prefix+'/libs') + flatten_dependencies(spec, prefix+'/libs') + +def flatten_dependencies(spec, flat_dir): + """Make each dependency of spec present in dir via symlink.""" + for dep in spec.traverse(root=False): + name = dep.name + + dep_path = spack.install_layout.path_for_spec(dep) + dep_files = LinkTree(dep_path) + + os.mkdir(flat_dir+'/'+name) + + conflict = dep_files.find_conflict(flat_dir+'/'+name) + if conflict: + raise DependencyConflictError(conflict) + + dep_files.merge(flat_dir+'/'+name) + + def validate_package_url(url_string): """Determine whether spack can handle a particular URL or not.""" url = urlparse(url_string) @@ -1348,3 +1370,11 @@ class ExtensionConflictError(ExtensionError): class ActivationError(ExtensionError): def __init__(self, msg, long_msg=None): super(ActivationError, self).__init__(msg, long_msg) + + +class DependencyConflictError(spack.error.SpackError): + """Raised when the dependencies cannot be flattened as asked for.""" + def __init__(self, conflict): + super(DependencyConflictError, self).__init__( + "%s conflicts with another file in the flattened directory." %( + conflict)) -- cgit v1.2.3-60-g2f50 From af7e3cadde02b2ab9b6de2c588a41663141928dd Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 18 Mar 2016 11:34:07 -0700 Subject: cleanup --- lib/spack/spack/directory_layout.py | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index e275031387..242eb1afa0 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -33,7 +33,6 @@ import yaml import llnl.util.tty as tty from llnl.util.filesystem import join_path, mkdirp -from llnl.util.link_tree import * from spack.spec import Spec from spack.error import SpackError -- cgit v1.2.3-60-g2f50 From 151b04637ef01b8cde5967df6165bd245311b90a Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 18 Mar 2016 11:55:31 -0700 Subject: changed function name and removed hardcoded libs dir --- lib/spack/spack/__init__.py | 4 ++-- lib/spack/spack/package.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index 155e190597..5d62d597cb 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -175,5 +175,5 @@ import spack.util.executable from spack.util.executable import * __all__ += spack.util.executable.__all__ -from spack.package import flat_install, flatten_dependencies, DependencyConflictError -__all__ += ['flat_install', 'flatten_dependencies', 'DependencyConflictError'] +from spack.package import install_dependency_symlinks, flatten_dependencies, DependencyConflictError +__all__ += ['install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError'] diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 1a962268cf..4c458522e0 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1211,10 +1211,9 @@ class Package(object): return " ".join("-Wl,-rpath,%s" % p for p in self.rpath) -def flat_install(pkg, spec, prefix): +def install_dependency_symlinks(pkg, spec, prefix): """Execute a dummy install and flatten dependencies""" - os.mkdir(prefix+'/libs') - flatten_dependencies(spec, prefix+'/libs') + flatten_dependencies(spec, prefix) def flatten_dependencies(spec, flat_dir): """Make each dependency of spec present in dir via symlink.""" -- cgit v1.2.3-60-g2f50 From 23f3f1adfe01f7b1301959e7e54584724679c7b3 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 18 Mar 2016 13:32:37 -0700 Subject: Make InstallError and ExternalPackageError visiible in packages. --- lib/spack/spack/__init__.py | 8 ++++++-- lib/spack/spack/package.py | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index 0ba42bbbfc..aee11f061f 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -189,5 +189,9 @@ import spack.util.executable from spack.util.executable import * __all__ += spack.util.executable.__all__ -from spack.package import install_dependency_symlinks, flatten_dependencies, DependencyConflictError -__all__ += ['install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError'] +from spack.package import \ + install_dependency_symlinks, flatten_dependencies, DependencyConflictError, \ + InstallError, ExternalPackageError +__all__ += [ + 'install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError', + 'InstallError', 'ExternalPackageError'] diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index b488e4c49d..dafad0b184 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1351,6 +1351,10 @@ class InstallError(spack.error.SpackError): super(InstallError, self).__init__(message, long_msg) +class ExternalPackageError(InstallError): + """Raised by install() when a package is only for external use.""" + + class PackageStillNeededError(InstallError): """Raised when package is still needed by another on uninstall.""" def __init__(self, spec, dependents): -- cgit v1.2.3-60-g2f50 From e9126baaabbfaa5e12641b3d44a5c5fd49e43ca3 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 18 Mar 2016 13:42:45 -0700 Subject: Add docs for InstallError. --- lib/spack/docs/packaging_guide.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst index c1077e4497..519c0da232 100644 --- a/lib/spack/docs/packaging_guide.rst +++ b/lib/spack/docs/packaging_guide.rst @@ -1844,6 +1844,20 @@ dedicated process. .. _prefix-objects: + +Failing the build +---------------------- + +Sometimes you don't want a package to successfully install unless some +condition is true. You can explicitly cause the build to fail from +``install()`` by raising an ``InstallError``, for example: + +.. code-block:: python + + if spec.architecture.startswith('darwin'): + raise InstallError('This package does not build on Mac OS X!') + + Prefix objects ---------------------- -- cgit v1.2.3-60-g2f50