MCPcopy Index your code
hub / github.com/pyinstaller/pyinstaller / check_python_headers

Function check_python_headers

bootloader/waflib/Tools/python.py:256–431  ·  view source on GitHub ↗
(conf, features='pyembed pyext')

Source from the content-addressed store, hash-verified

254
255@conf
256def check_python_headers(conf, features='pyembed pyext'):
257 features = Utils.to_list(features)
258 assert ('pyembed' in features
259 ) or ('pyext' in features), "check_python_headers features must include 'pyembed' and/or 'pyext'"
260 env = conf.env
261 if not env.CC_NAME and not env.CXX_NAME:
262 conf.fatal('load a compiler first (gcc, g++, ..)')
263 if conf.python_cross_compile(features):
264 return
265 if not env.PYTHON_VERSION:
266 conf.check_python_version()
267 pybin = env.PYTHON
268 if not pybin:
269 conf.fatal('Could not find the python executable')
270 v = 'prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split(
271 )
272 try:
273 lst = conf.get_python_variables(["get_config_var('%s') or ''" % x for x in v])
274 except RuntimeError:
275 conf.fatal("Python development headers not found (-v for details).")
276 vals = ['%s = %r' % (x, y) for (x, y) in zip(v, lst)]
277 conf.to_log("Configuration returned from %r:\n%s\n" % (pybin, '\n'.join(vals)))
278 dct = dict(zip(v, lst))
279 x = 'MACOSX_DEPLOYMENT_TARGET'
280 if dct[x]:
281 env[x] = conf.environ[x] = dct[x]
282 env.pyext_PATTERN = '%s' + dct['SO']
283 num = '.'.join(env.PYTHON_VERSION.split('.')[:2])
284 conf.find_program([
285 ''.join(pybin) + '-config',
286 'python%s-config' % num,
287 'python-config-%s' % num,
288 'python%sm-config' % num
289 ],
290 var='PYTHON_CONFIG',
291 msg="python-config",
292 mandatory=False)
293 if env.PYTHON_CONFIG:
294 if conf.env.HAVE_PYTHON_H:
295 return
296 all_flags = [['--cflags', '--libs', '--ldflags']]
297 if sys.hexversion < 0x2070000:
298 all_flags = [[k] for k in all_flags[0]]
299 xx = env.CXX_NAME and 'cxx' or 'c'
300 if 'pyembed' in features:
301 for flags in all_flags:
302 embedflags = flags + ['--embed']
303 try:
304 conf.check_cfg(
305 msg='Asking python-config for pyembed %r flags' % ' '.join(embedflags),
306 path=env.PYTHON_CONFIG,
307 package='',
308 uselib_store='PYEMBED',
309 args=embedflags
310 )
311 except conf.errors.ConfigurationError:
312 conf.check_cfg(
313 msg='Asking python-config for pyembed %r flags' % ' '.join(flags),

Callers

nothing calls this directly

Calls 7

to_listMethod · 0.80
fatalMethod · 0.80
append_uniqueMethod · 0.80
checkMethod · 0.80
append_valueMethod · 0.80
initializeMethod · 0.80
to_logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…