dumb distutils question (distutils vs. LDFLAGS)

Quinn Dunkan quinn at regurgitate.ugcs.caltech.edu
Thu May 23 14:11:16 EDT 2002


I have a seemingly basic question but cannot find the answer.

How do you get python (and extensions modules, but I'm currently trying to
build python) to look in the include and lib directories you want?  I'd think
this is a common problem because libs required for some extensions are in
/usr/local/lib or /opt/foo/lib or /usr/local/bar/lib on many systems.

I can do 'CFLAGS=-I/opt/sfw/include LDFLAGS=-L/opt/sfw/lib ./configure', but
then configure ignores that and compiles everything with its own flags
(including -O3, what's the deal with that, anyway?  all the gcc docs I've read
say "-O3 *may* improve speed, or may hurt it, but will definately increase
size and is most likely to be buggy", so why is python using it?).

Anyway, I've *never* been able to get along with configure, but since I only
need the extensions to look for the libs in the right place, I could just
'make', SIGINT when it runs setup.py, and then re-run setup.py by hand with
flags (is there a more graceful way?).  Unfortunately, I can't tell which
flags.  The closest thing the docs have is '* CFLAGS and LDFLAGS (must
implement them first!)' in 'Installing Python Modules (3)'.  Some greps through
the source revealed ldflags munging for some specific windows compilers and a
whole bunch of 'XXX we should support this' in build_ext.py.  So it looks to me
like there's no way to use "custom" library directories, short of looking
through distutils source to figure out its internals and hacking setup.py to
frob 'ldflags' directly.

This isn't such a rare thing to want---who *doesn't* have libraries in places
like /usr/local/lib or wherever?  Is there some easier way to do this that I'm
missing?



More information about the Python-list mailing list