[Distutils] Parsing config files + passing options

Brad Chapman Brad Chapman <chapmanb@arches.uga.edu>
Thu, 11 May 2000 10:29:19 -0400


Hello all!
    I've been playing around with Distutils-0.8.2 and just have a few 
questions. Before I start though, thanks for all your work on this so 
far, it is *very* nice and much needed!
    I just have two questions:

1. I'm working on writing a setup.py for an extension that uses gnome 
and glib libraries, and was curious if there was a general way anyone 
has already thought of to handle getting information from gnome-config 
and glib-config calls into a form that you can input into Distutils. 

For instance, if I do something like the following:

>>> import commands
>>> gthread_cflags = commands.getoutput("glib-config --cflags gthread")
>>> print gthread_cflags
-I/usr/local/include/glib12 -D_THREAD_SAFE

I can get the options you would pass. It would be useful to have 
something to process this like:

def parse_cflag_config(configure_script, library)

which would then return two lists, the include dirs and the macros. So 
they you could do something in your setup.py like:

gthread_includes, gthread_macros = parse_cflag_config("glib-config", 
"gthread")

Of course, this would only work on UNIX, but that is where the config 
calls are anyways :-)

Is this something that would be generally useful to anyone? Does this 
approach seem like a good idea? Is there already a better plan in 
place to handle this?

2. Going along with this first problem, I was also wondering how to 
pass specific compiler flags. The issue I have is that on FreeBSD, 
there is a FreeBSD specific option for linking the thread libraries: 
'-pthread' (what this option does is link in libc_r and not libc, if 
anyone cares. I'm afraid I'm not smart enough to more about it than 
that :-). 
    Anyways, is there a way to pass a flag like '-pthread'? Apologies 
if I missed it!

Thanks much for listening and thanks again for the wonderful tool.

Brad