Add include/pythonX.Y to CPATH (#14523)

This commit is contained in:
Adam J. Stewart 2020-01-16 15:21:14 -06:00 committed by GitHub
parent 0f68ed73c6
commit 7a61d1dbd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -678,6 +678,7 @@ def libs(self):
@property @property
def headers(self): def headers(self):
try:
config_h = self.get_config_h_filename() config_h = self.get_config_h_filename()
if not os.path.exists(config_h): if not os.path.exists(config_h):
@ -686,6 +687,11 @@ def headers(self):
raise RuntimeError(msg.format(self.name, includepy)) raise RuntimeError(msg.format(self.name, includepy))
headers = HeaderList(config_h) headers = HeaderList(config_h)
except ProcessError:
headers = find_headers(
'pyconfig', self.prefix.include, recursive=True)
config_h = headers[0]
headers.directories = [os.path.dirname(config_h)] headers.directories = [os.path.dirname(config_h)]
return headers return headers
@ -705,6 +711,9 @@ def site_packages_dir(self):
def easy_install_file(self): def easy_install_file(self):
return join_path(self.site_packages_dir, "easy-install.pth") return join_path(self.site_packages_dir, "easy-install.pth")
def setup_run_environment(self, env):
env.prepend_path('CPATH', os.pathsep.join(self.headers.directories))
def setup_dependent_build_environment(self, env, dependent_spec): def setup_dependent_build_environment(self, env, dependent_spec):
"""Set PYTHONPATH to include the site-packages directory for the """Set PYTHONPATH to include the site-packages directory for the
extension and any other python extensions it depends on.""" extension and any other python extensions it depends on."""