python: fix clingo bootstrapping on Apple M1/M2 (#31792)

This commit is contained in:
Adam J. Stewart 2022-08-01 08:48:07 -07:00 committed by GitHub
parent ae3c039908
commit 90dbfea895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -74,8 +74,8 @@ def cmake_python_hints(self):
"""
python = self.spec["python"]
return [
self.define("Python_EXECUTABLE", str(python.command)),
self.define("Python_INCLUDE_DIR", python.package.config_vars["include"]),
self.define("Python_EXECUTABLE", python.command),
self.define("Python_INCLUDE_DIR", python.headers.directories[0]),
]
@property

View File

@ -961,6 +961,7 @@ def config_vars(self):
# get_config_vars
"BINDIR": self.prefix.bin,
"CC": "cc",
"CONFINCLUDEPY": self.prefix.include.join("python{}").format(version),
"CXX": "c++",
"INCLUDEPY": self.prefix.include.join("python{}").format(version),
"LIBDEST": self.prefix.lib.join("python{}").format(version),
@ -1098,15 +1099,17 @@ def libs(self):
@property
def headers(self):
directory = self.config_vars["include"]
# Location where pyconfig.h is _supposed_ to be
config_h = self.config_vars["config_h_filename"]
if os.path.exists(config_h):
headers = HeaderList(config_h)
else:
headers = find_headers("pyconfig", directory)
if headers:
config_h = headers[0]
# If not, one of these config vars should contain the right directory
for var in ["INCLUDEPY", "CONFINCLUDEPY"]:
headers = find_headers("pyconfig", self.config_vars[var])
if headers:
config_h = headers[0]
break
else:
msg = "Unable to locate {} headers in {}"
raise spack.error.NoHeadersError(msg.format(self.name, directory))