I maintain a software collection that installs to an alternate prefix, and
some of the longstanding issues I've seen with Python packages is that
distutils doesn't seem to have any mechanism to allow a package build script to
distinguish between project include directories and system include directories,
and therefore include_dirs gets used for both purposes. The main issue is that
project include directories should preceed anything specified in CPPFLAGS,
whereas system include directories should follow CPPFLAGS. I've had a look at
distutils2 and the situation is pretty much the same there.
I finally decided to spend some time exploring this issue, and
ended up creating a fairly extensive modification of the distutils that was
shipped with Python-2.7.9, and also of the numpy and scipy packages. They take
the approach of having cc_args precede the CPPFLAGS. This leaves
extra_compile_args as a possible mechanism for system includes.
Links to my patches are below. So far I like the effect they've had. Adding
parsed environment variables to "extensions" is a little beyond its stated
scope, but it has the benefit of unifying the treatment of command line options
and of giving the user the opportunity to bind options tightly to the compiler
command by adding options there, or to leave them, for example, in CFLAGS,
where they can potentially be overriden by the package distribution. I also
like the fact that the modifications make "compiler_exe" and "compiler_so"
disappear, and leave "compiler", "compiler_flags_so", and "compiler_flags_exe"
instead. That seems like a a cleaner model of the commands involved. I'm
considering adding a "sysincludedirs" argument to Extension().
Using the disutils packaged with Python-2.7.9, numpy wasn't doing the right
thing, and compiler flags weren't making it into the Fortran command lines.
with these modifications and the numpy modifications, things are working
I would appreciate any feedback anyone interested might have after glancing
over the patches.