[New-bugs-announce] [issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

Christian Heimes report at bugs.python.org
Fri Oct 22 11:22:43 EDT 2021


New submission from Christian Heimes <lists at cheimes.de>:

pkg-config [1] is a standard tool on Linux and other platforms to detect presence of dependencies as well as to figure out which compiler and linker flags they require. Development packages provide a .pc file, e.g. ncurses provides a ncursesw.pc file.

$ pkg-config --libs --cflags ncursesw
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lncursesw -ltinfo

I propose to use a modified version of pkg-config's PKG_HAVE_DEFINE_WITH_MODULES macro in our configure script. On succss the modified macro defines:

* HAVE_FOO=1
* FOO_CFLAGS="some compile flags"
* FOO_LIBS="some library flags for linker"

On error, it sets nothing and does not cause configure to stop with an error.

The macro also allows users to override flags by setting FOO_CFLAGS and FOO_LIBS env vars. HAVE_FOO is added to pyconfig.h. The FOO_CFLAGS/LIBS are added to Makefile, from where it can be consumed by Modules/Setup.

Eventually Python could use the flags in setup.py, too. For now I would like to start with Modules/Setup. It is only used by some power users and has less risk of breaking the setup of beginners.

[1] https://www.freedesktop.org/wiki/Software/pkg-config/

----------
assignee: christian.heimes
components: Build
messages: 404781
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: Use pkg-config autoconf macros to detect flags for Modules/Setup
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45573>
_______________________________________


More information about the New-bugs-announce mailing list