diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-03-27 16:10:05 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2016-03-27 16:10:05 -0700 |
commit | 8b45d6f84fdb2ee627a76f412fd8cc12b206046a (patch) | |
tree | 50c46e9b934fe784bda330871fd6f9df7598dbc0 /lib | |
parent | 82c09e66d22933303f4284713f5daf464d733975 (diff) | |
parent | 7eca1284c81c3efc5a87b8a174a0974811656b3e (diff) | |
download | spack-8b45d6f84fdb2ee627a76f412fd8cc12b206046a.tar.gz spack-8b45d6f84fdb2ee627a76f412fd8cc12b206046a.tar.bz2 spack-8b45d6f84fdb2ee627a76f412fd8cc12b206046a.tar.xz spack-8b45d6f84fdb2ee627a76f412fd8cc12b206046a.zip |
Merge pull request #658 from davydden/metis_parmetis_darwin
metis/parmetis/oce/boost: correct install_name on Darwin via a global tool
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 30 |
1 files changed, 29 insertions, 1 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 |