[Distutils] patch to unixccompiler.py
Greg Ward
gward@cnri.reston.va.us
Tue, 1 Feb 2000 19:11:14 -0500
On 01 February 2000, Joe Van Andel said:
> I've encountered a situation where I'd like to be able to over-ride the
> default compiler used by distutils. I have an extension which requires
> a newer version of gcc than I used to build python.
>
> The following patch uses the value of the CC environment variable to
> override the default. I'd like to see this in the next version of
> distutils, if possible:
Hmm. I'm a bit leery of introducing environment variables into the user
interface; they're prone to action-at-a-distance and unintended
consequence. However, it would be convenient to be able to adopt the
time-honoured idiom of
CC=foo_cc make
to
CC=foo_cc python setup.py build
I think the proper way to do it would be to add an option to the
build_ext command, so you'd have to do something like this:
python setup.py build_ext --compiler=foo_cc
(This might also be a good way to override compiler flags -- add a
"--compiler-flags" option.) This would require rather more code than
Joe's tiny little patch, though.
> *** unixccompiler.orig Sun Dec 12 09:57:47 1999
> --- unixccompiler.py Tue Feb 1 13:58:39 2000
> ***************
> *** 22,27 ****
> --- 22,32 ----
> from copy import copy
> from sysconfig import \
> CC, CCSHARED, CFLAGS, OPT, LDSHARED, LDFLAGS, RANLIB, AR, SO
> + import os
> + tcc = os.environ.get('CC')
> + if tcc:
> + CC=tcc
> +
> from ccompiler import CCompiler, gen_preprocess_options,
> gen_lib_options
> from util import move_file, newer_pairwise, newer_group
Anyone have strong feelings one way or the other about accepting this
patch and making environment variables a part of the Distutils user
interface?
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913