summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2022-08-14 16:09:34 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2022-08-17 10:42:15 -0700
commit73d25984ca898bcfeea6625d78961fb96c9b0f99 (patch)
tree8416acf9a1c6e79a597d896a0196126d62d6c20e
parent50f8a0f0d6a70888197324a136dcdb45f0acc8ff (diff)
downloadspack-73d25984ca898bcfeea6625d78961fb96c9b0f99.tar.gz
spack-73d25984ca898bcfeea6625d78961fb96c9b0f99.tar.bz2
spack-73d25984ca898bcfeea6625d78961fb96c9b0f99.tar.xz
spack-73d25984ca898bcfeea6625d78961fb96c9b0f99.zip
clingo: fix bootstrapping on M1/monterey with command line tools
The Python that comes with XCode command line tools is a bit weird. This fixes two issues that were preventing it from bootstrapping: - [x] CommandLineTools python does not come with a `python-config` executable. If you don't have one of these, CMake's FindPython will, for some reason, assume that you want Python 2, so you need to set `CLINGO_PYTHON_VERSION` to ensure that clingo tells `find_package(Python <VERSION>)` the right thing. - [x] We weren't setting `PYTHONHOME` correctly in Python's `package.py`. We were setting it to the `prefix` from Python `sysconfig`, but `prefix` tells you where the executable lives. CommandLineTools python reports its prefix as /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8 but that doesn't exist. It looks like Apple builds the full python and just copies pieces of it into command line tools. PYTHONHOME is supposed to tell you where the default python library location is. So you have to look at the `base`, which `sysconfig` reports as /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8 On most systems this is probably the same as `prefix`, but not with CommandLineTools, which has its system library in a different place. The second change here was cherry-picked to 0d981a012d before merging and doesn't show up here. Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
-rw-r--r--var/spack/repos/builtin/packages/clingo/package.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/clingo/package.py b/var/spack/repos/builtin/packages/clingo/package.py
index bef3e146cb..4315d6a0bc 100644
--- a/var/spack/repos/builtin/packages/clingo/package.py
+++ b/var/spack/repos/builtin/packages/clingo/package.py
@@ -74,8 +74,13 @@ class Clingo(CMakePackage):
"""
python = self.spec["python"]
return [
- self.define("Python_EXECUTABLE", python.command),
+ self.define("Python_EXECUTABLE", python.command.path),
self.define("Python_INCLUDE_DIR", python.headers.directories[0]),
+ self.define("Python_LIBRARIES", python.libs[0]),
+ # XCode command line tools on macOS has no python-config executable, and
+ # CMake assumes you have python 2 if it does not find a python-config,
+ # so we set the version explicitly so that it's passed to FindPython.
+ self.define("CLINGO_PYTHON_VERSION", python.version.up_to(2)),
]
@property