AC macro for embedding python?

Brendan Cully brendan at kublai.com
Sun Mar 2 17:15:41 EST 2003


Hi,

I've been doing a lot of searching through the python-list archive looking for a
nice way to have autoconf figure out what compiler and linker flags are needed
in order to embed python into an application. (For the curious, the application
in question is ices, an icecast/shoutcast MP3/Ogg streamer. Its playlist is
scriptable in perl and python as the user prefers. The actual embedded python
interpreter has worked fine for a couple of years - I'm just trying to give
it better autoconf support).

In spite of what seems to me to be an obvious need for it, it looks like there
is no standard way of getting all the flags needed for embedding. So, I intend
to write some kind of AC_PATH_PYTHON macro to set the appropriate
PYTHON_INCLUDES and PYTHON_LIBS variables. I'm looking for a little guidance
on what the current best practices are for discovering these. As far as I
can tell what we have so far is:

1. Find the python executable
2. Run a script to import distutils.sysconfig and capture LIBS and SYSLIBS for
   extra libraries, LIBPL for LDFLAGS, INCLUDEPY for CPPFLAGS, and
   LINKFORSHARED for LDFLAGS if we want to use any modules that use extensions.

I'm just grabbing these variables because they look most appropriate from the
get_config_vars dictionary. I have no idea whether they are the best to use.

Does anyone know of a better approach, or have any other comments before I write
this thing?

-b





More information about the Python-list mailing list