Make fix_darwin_install_name python3-compatible (#7329)
This updates the fix_darwin_install_name function to use the Spack Executable object to run install_name_tool, which ensures that process output is formatted as a 'str' for python2 and python3. Originally fix_darwin_install_name was invoking subprocess.Popen directly.
This commit is contained in:
parent
7db35ff05c
commit
4a807fca08
1 changed files with 6 additions and 10 deletions
|
@ -32,7 +32,6 @@
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
@ -40,6 +39,7 @@
|
||||||
import six
|
import six
|
||||||
from llnl.util import tty
|
from llnl.util import tty
|
||||||
from llnl.util.lang import dedupe
|
from llnl.util.lang import dedupe
|
||||||
|
from spack.util.executable import Executable
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'FileFilter',
|
'FileFilter',
|
||||||
|
@ -583,12 +583,10 @@ def fix_darwin_install_name(path):
|
||||||
libs = glob.glob(join_path(path, "*.dylib"))
|
libs = glob.glob(join_path(path, "*.dylib"))
|
||||||
for lib in libs:
|
for lib in libs:
|
||||||
# fix install name first:
|
# fix install name first:
|
||||||
subprocess.Popen(
|
install_name_tool = Executable('install_name_tool')
|
||||||
["install_name_tool", "-id", lib, lib],
|
install_name_tool('-id', lib, lib)
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
otool = Executable('otool')
|
||||||
long_deps = subprocess.Popen(
|
long_deps = otool('-L', lib, output=str).split('\n')
|
||||||
["otool", "-L", lib],
|
|
||||||
stdout=subprocess.PIPE).communicate()[0].split('\n')
|
|
||||||
deps = [dep.partition(' ')[0][1::] for dep in long_deps[2:-1]]
|
deps = [dep.partition(' ')[0][1::] for dep in long_deps[2:-1]]
|
||||||
# fix all dependencies:
|
# fix all dependencies:
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
|
@ -599,9 +597,7 @@ def fix_darwin_install_name(path):
|
||||||
# but we don't know builddir (nor how symbolic links look
|
# but we don't know builddir (nor how symbolic links look
|
||||||
# in builddir). We thus only compare the basenames.
|
# in builddir). We thus only compare the basenames.
|
||||||
if os.path.basename(dep) == os.path.basename(loc):
|
if os.path.basename(dep) == os.path.basename(loc):
|
||||||
subprocess.Popen(
|
install_name_tool('-change', dep, loc, lib)
|
||||||
["install_name_tool", "-change", dep, loc, lib],
|
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue