PYTHON-CONFIG(1)

πŸ“¦ version 3.12.3, in ubuntu noble

✨ PYTHON-CONFIG(1) ✨

okay so python-config is the manual page for the python-config tool, and it's literally the cutest helper for spitting out build options for python C/C++ extensions or embedding πŸ’…πŸ


πŸŽ€ NAME πŸŽ€

python-config - output build options for python C/C++ extensions or embedding


πŸ¦‹ SYNOPSIS πŸ¦‹

python-config [ --prefix ] [ --exec-prefix ] [ --includes ] [ --libs ] [ --cflags ] [ --ldflags ] [ --extension-suffix ] [ --abiflags ] [ --help ]

πŸ’– DESCRIPTION πŸ’–

okay bestie, so python-config helps you compile and link programs that embed the Python interpreter, or extension modules that can get loaded dynamically (at run time) into the interpreter. it's giving build-helper energy and I'm obsessed 😭✨


🌸 OPTIONS 🌸

  • --abiflags β€” prints the the ABI flags as specified by PEP 3149. ✨
  • --cflags β€” prints the C compiler flags. πŸ’…
  • --ldflags β€” prints the flags that should be passed to the linker. πŸ”—
  • --includes β€” similar to --cflags but only with -I options (path to python header files). 🧚
  • --libs β€” similar to --ldflags but only with -l options (used libraries). πŸ’œ
  • --prefix β€” prints the prefix (base directory) under which python can be found. πŸ“
  • --exec-prefix β€” prints the prefix used for executable program directories (such as bin, sbin, etc). 🌈
  • --extension-suffix β€” prints the extension suffix used for binary extensions. πŸŽ€
  • --help β€” prints the usage message. 🫢

🧚 EXAMPLES 🧚

To build the singe-file c program prog against the python library, use

gcc $(python-config --cflags --ldflags) progr.cpp -o progr.cpp

The same in a makefile:

CFLAGS+=$(shell python-config --cflags)
LDFLAGS+=$(shell python-config --ldflags)
all: progr

To build a dynamically loadable python module, use

gcc $(python-config --cflags --ldflags) -shared -fPIC progr.cpp -o progr.so

πŸ”₯ SEE ALSO πŸ”₯

  • python (1) β€” the main python interpreter, obviously πŸ‘‘
  • http://docs.python.org/extending/extending.html β€” the official extending docs πŸ“š
  • /usr/share/doc/python/faq/extending.html β€” the local FAQ on extending, for when you're offline πŸ’€

🌈 AUTHORS 🌈

this manual page was written by Johann Felix Soden <johfel@gmx.de> for the Debian project (and may be used by others). ily Johann 🫢


bestie, that's the whole page!! πŸ’œ It was last updated November 27, 2011, and it's the PYTHON-CONFIG(1) manual, so go forth and build something iconic βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from