Hi,

On 2022-01-23 18:53:01 -0800, Andres Freund wrote:
> I don't really understand what the various "platform" variables / paths are
> supposed to do.

The code says:


> def get_python_inc(plat_specific=0, prefix=None):
>     """Return the directory containing installed Python header files.
> 
>     If 'plat_specific' is false (the default), this is the path to the
>     non-platform-specific header files, i.e. Python.h and so on;
>     otherwise, this is the path to platform-specific header files
>     (namely pyconfig.h).
>     ...

Looking at the code for get_python_inc() in 2.7, it seems that plat_specific
toggles between CONFINCLUDEPY and INCLUDEPY. Except on windows, where it uses
get_path('include') for both. sysconfig.py sets INCLUDEPY to
get_path('include') on windows, so we'd be good with INCLUDEPY there.



> To avoid too noisy breakages, we could have python.m4 emit INCLUDEPY and then
> search the bf logs in a day or three?

Maybe something like the attached? Not particularly nice, but should give us
most of the relevant information?

Greetings,

Andres Freund
diff --git i/config/python.m4 w/config/python.m4
index f51d23c3d43..46829b5b117 100644
--- i/config/python.m4
+++ w/config/python.m4
@@ -68,6 +68,27 @@ if test "$PORTNAME" = win32 ; then
 fi
 AC_MSG_RESULT([$python_includespec])
 
+python_ways=`${PYTHON} -c "
+import distutils.sysconfig as ds
+import os
+import sysconfig as s
+print('ds.get_python_inc(False): %s' % ds.get_python_inc(False))
+print('s path include: %s' % s.get_path('include'))
+print('ds.get_python_inc(True): %s' % ds.get_python_inc(True))
+print('s path platinclude: %s' % s.get_path('platinclude'))
+print('ds var INCLUDEPY: %s' % ds.get_config_var('INCLUDEPY'))
+print('s var INCLUDEPY: %s' % s.get_config_var('INCLUDEPY'))
+print('ds var CONFINCLUDEPY: %s' % ds.get_config_var('CONFINCLUDEPY'))
+print('s var CONFINCLUDEPY: %s' % s.get_config_var('CONFINCLUDEPY'))
+print('')
+print('ds get_python_inc(False)/Python.h exists: %s' % os.path.exists(os.path.join(ds.get_python_inc(False), 'Python.h')))
+print('ds get_python_inc(True)/Python.h exists: %s' % os.path.exists(os.path.join(ds.get_python_inc(True), 'Python.h')))
+print('s var INCLUDEPY/Python.h exists: %s' % os.path.exists(os.path.join(ds.get_config_var('INCLUDEPY'), 'Python.h')))
+print('s var CONFINCLUDEPY/Python.h exists: %s' % os.path.exists(os.path.join(ds.get_config_var('CONFINCLUDEPY'), 'Python.h')))
+"` 2>/dev/null
+AC_MSG_NOTICE([python include paths, different approaches:
+$python_ways])
+
 AC_SUBST(python_majorversion)[]dnl
 AC_SUBST(python_version)[]dnl
 AC_SUBST(python_includespec)[]dnl

Reply via email to