This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Shell python-config --includes returns the same path twice
Type: Stage: resolved
Components: Build Versions: Python 3.9
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: doko, hroncok, vstinner
Priority: normal Keywords:

Created on 2019-10-28 16:17 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg355561 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-28 16:17
When the shell script implementation of python-config was introduced, $PLATINCDIR variable was added:

commit 874211978c8097b8e747c90fa3ff41aacabe340f
Author: doko@python.org <doko@python.org>
Date:   Sat Jan 26 11:39:31 2013 +0100

    - Issue #16235: Implement python-config as a shell script.

...
+INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
+PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
...
+        --includes)
+            echo "$INCDIR $PLATINCDIR"
+        ;;
+        --cflags)
+            echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
+        ;;
...

But this variable is always equal to $INCDIR: it doesn't seem possible to change its value.

What is the purpose of emitting the same path twice?

Example on Fedora 30:

$ file /usr/bin/python3.8-x86_64-config 
/usr/bin/python3.8-x86_64-config: a /usr/bin/sh script, ..

$ /usr/bin/python3.8-x86_64-config --includes
-I/usr/include/python3.8 -I/usr/include/python3.8

=> /usr/include/python3.8 is giving twice
msg355659 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2019-10-29 16:09
Some distros have two include directories in the path,

 /usr/include
 /usr/include/<multiarch>

The latter for architecture specific files, so on these distributions the python config file is installed there.  Then you'll need to have both include directories.  Unfortunately most third party only expect one, and because the config file is installed in a subdir, then fail to build.

So the solution is to provide a rather arch specific ugly wrapper file to get away with one include directory.

https://salsa.debian.org/cpython-team/python3/blob/master/debian/multiarch.h.in

Also done on other distros like
https://src.fedoraproject.org/rpms/gmp/blob/master/f/gmp.h

I still think the two directories should be emitted, maybe check in the script if they are different.
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82801
2021-09-21 22:29:15vstinnersetstatus: open -> closed
resolution: out of date
stage: resolved
2019-10-29 16:09:10dokosetmessages: + msg355659
2019-10-29 15:58:17hroncoksetnosy: + hroncok
2019-10-28 16:17:26vstinnercreate