summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/filesystem.py30
-rw-r--r--lib/spack/llnl/util/lang.py6
-rw-r--r--lib/spack/spack/cmd/info.py4
-rw-r--r--lib/spack/spack/modules.py4
4 files changed, 37 insertions, 7 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index c4665c284c..46ca03bec4 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -27,9 +27,10 @@ __all__ = ['set_install_permissions', 'install', 'install_tree', 'traverse_tree'
'force_remove', 'join_path', 'ancestor', 'can_access', 'filter_file',
'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink',
'set_executable', 'copy_mode', 'unset_executable_mode',
- 'remove_dead_links', 'remove_linked_tree']
+ 'remove_dead_links', 'remove_linked_tree', 'fix_darwin_install_name']
import os
+import glob
import sys
import re
import shutil
@@ -38,6 +39,7 @@ import errno
import getpass
from contextlib import contextmanager, closing
from tempfile import NamedTemporaryFile
+import subprocess
import llnl.util.tty as tty
from spack.util.compression import ALLOWED_ARCHIVE_TYPES
@@ -392,3 +394,29 @@ def remove_linked_tree(path):
os.unlink(path)
else:
shutil.rmtree(path, True)
+
+def fix_darwin_install_name(path):
+ """
+ Fix install name of dynamic libraries on Darwin to have full path.
+ There are two parts of this task:
+ (i) use install_name('-id',...) to change install name of a single lib;
+ (ii) use install_name('-change',...) to change the cross linking between libs.
+ The function assumes that all libraries are in one folder and currently won't
+ follow subfolders.
+
+ Args:
+ path: directory in which .dylib files are alocated
+
+ """
+ libs = glob.glob(join_path(path,"*.dylib"))
+ for lib in libs:
+ # fix install name first:
+ subprocess.Popen(["install_name_tool", "-id",lib,lib], stdout=subprocess.PIPE).communicate()[0]
+ long_deps = subprocess.Popen(["otool", "-L",lib], stdout=subprocess.PIPE).communicate()[0].split('\n')
+ deps = [dep.partition(' ')[0][1::] for dep in long_deps[2:-1]]
+ # fix all dependencies:
+ for dep in deps:
+ for loc in libs:
+ if dep == os.path.basename(loc):
+ subprocess.Popen(["install_name_tool", "-change",dep,loc,lib], stdout=subprocess.PIPE).communicate()[0]
+ break
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index 13d301f84e..3b4e2c8352 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -117,7 +117,8 @@ def caller_locals():
scope. Yes, this is some black magic, and yes it's useful
for implementing things like depends_on and provides.
"""
- stack = inspect.stack()
+ # Passing zero here skips line context for speed.
+ stack = inspect.stack(0)
try:
return stack[2][0].f_locals
finally:
@@ -128,7 +129,8 @@ def get_calling_module_name():
"""Make sure that the caller is a class definition, and return the
enclosing module's name.
"""
- stack = inspect.stack()
+ # Passing zero here skips line context for speed.
+ stack = inspect.stack(0)
try:
# Make sure locals contain __module__
caller_locals = stack[2][0].f_locals
diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py
index e7abe7f4a5..c93db55c63 100644
--- a/lib/spack/spack/cmd/info.py
+++ b/lib/spack/spack/cmd/info.py
@@ -52,7 +52,7 @@ def print_text_info(pkg):
print "Safe versions: "
if not pkg.versions:
- print("None")
+ print(" None")
else:
pad = padder(pkg.versions, 4)
for v in reversed(sorted(pkg.versions)):
@@ -62,7 +62,7 @@ def print_text_info(pkg):
print
print "Variants:"
if not pkg.variants:
- print "None"
+ print " None"
else:
pad = padder(pkg.variants, 4)
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index d45fdde703..f6a11c92e3 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -278,6 +278,6 @@ class TclModule(EnvModule):
# Long description
if self.long_description:
module_file.write('proc ModulesHelp { } {\n')
- doc = re.sub(r'"', '\"', self.long_description)
- module_file.write("puts stderr \"%s\"\n" % doc)
+ for line in textwrap.wrap(self.long_description, 72):
+ module_file.write("puts stderr \"%s\"\n" % line)
module_file.write('}\n\n')