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>
This commit is contained in:
parent
50f8a0f0d6
commit
73d25984ca
@ -74,8 +74,13 @@ def cmake_python_hints(self):
|
||||
"""
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user