summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <gamblin2@llnl.gov>2021-08-24 21:44:26 -0700
committerGitHub <noreply@github.com>2021-08-24 21:44:26 -0700
commitdf10e88e978ea1057401c56e7108dd271ae3151a (patch)
tree53c0f5c278b7ab2fd12f35e897c5af121be92f7f /lib
parent99076660d45e317cdb5262c65f3446cd23f36bf0 (diff)
downloadspack-df10e88e978ea1057401c56e7108dd271ae3151a.tar.gz
spack-df10e88e978ea1057401c56e7108dd271ae3151a.tar.bz2
spack-df10e88e978ea1057401c56e7108dd271ae3151a.tar.xz
spack-df10e88e978ea1057401c56e7108dd271ae3151a.zip
bootstrap: use `sys.exec_prefix` to set up external python correctly (#25593)
Bootstrapping clingo on macOS on `develop` gives errors like this: ``` ==> Error: RuntimeError: Unable to locate python command in /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/bin /Users/gamblin2/Workspace/spack/var/spack/repos/builtin/packages/python/package.py:662, in command: 659 return Executable(path) 660 else: 661 msg = 'Unable to locate {0} command in {1}' >> 662 raise RuntimeError(msg.format(self.name, self.prefix.bin)) ``` On macOS, `python` is laid out differently. In particular, `sys.executable` is here: ```console Python 2.7.16 (default, May 8 2021, 11:48:02) [GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.executable '/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python' ``` Based on that, you'd think that `/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents` would be where you'd look for a `bin` directory, but you (and Spack) would be wrong: ```console $ ls /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/ Info.plist MacOS/ PkgInfo Resources/ _CodeSignature/ version.plist ``` You need to look in `sys.exec_prefix` ``` >>> sys.exec_prefix '/System/Library/Frameworks/Python.framework/Versions/2.7' ``` Which looks much more like a standard prefix, with understandable `bin`, `lib`, and `include` directories: ```console $ ls /System/Library/Frameworks/Python.framework/Versions/2.7 Extras/ Mac/ Resources/ bin/ lib/ Headers@ Python* _CodeSignature/ include/ $ ls -l /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python lrwxr-xr-x 1 root wheel 7B Jan 1 2020 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python@ -> python2 ``` - [x] change `bootstrap.py` to use the `sys.exec_prefix` as the external prefix, instead of just getting the parent directory of the executable.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/bootstrap.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py
index 66cb2b49cf..09d9c6e3a8 100644
--- a/lib/spack/spack/bootstrap.py
+++ b/lib/spack/spack/bootstrap.py
@@ -267,7 +267,7 @@ def spack_python_interpreter():
which Spack is currently running as the only Python external spec
available.
"""
- python_prefix = os.path.dirname(os.path.dirname(sys.executable))
+ python_prefix = sys.exec_prefix
external_python = spec_for_current_python()
entry = {