From 73d25984ca898bcfeea6625d78961fb96c9b0f99 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 14 Aug 2022 16:09:34 -0700 Subject: 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 )` 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 --- var/spack/repos/builtin/packages/clingo/package.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'var') 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 -- cgit v1.2.3-70-g09d2