[Distutils] bdist and --compiler

Greg Ward gward@python.net
Fri, 26 May 2000 21:59:00 -0400


On 26 May 2000, Rene Liebscher said:
> Perhaps, someone else has a better overview and wants to start it. 
> At least it would be helpful to know all options which could 
> need more documentation.
> 
> So please, extend this list:
>  
> * build_ext, compiler : list of available compilers 
> (and their long names like 'Microsoft Visual C++ 5.X and higher' or so)
> 
> * bdist, format : list + explanation (gztar : creates XXXX.tar.gz)

That's all I can think of right now.  Here's a Stupid Unix Trick (TM) to
get help for all Distutils commands:

  ./setup.py --help `./setup.py --help-commands | awk '/^  [a-z]/ {print $1}'`

(err, assuming setup.py is executable and has a proper #! line).

Scanning the output of this, I see:

  build, build_ext, build_clib      --compiler
  sdist                             --formats
  bdist                             --formats

written that way because the three commands with --compiler have the
same list of compilers, but the two options with --format have different
lists of formats.  So yes, you got them all.  But there could well be
more in future, so I think it's worth adding a smidge of bureaucracy to
grease the wheels here.

Here's a strawman proposal for "custom help option" interface.  The
above five command classes (and any future commands with similar
requirements) would define a class attribute 'help_options':

class build (Command):
    # ...
    help_options = [('compiler', show_compilers,
                     "list available compilers (for --compiler option)")]

When 'parse_command_line()' (in Distribution) sees this list, it would
mangle each entry as appropriate to feed into the FancyGetopt parser, so 
that the following would appear in the help for "build":

  [...]
  --compiler (-c)    specify the compiler type
  --help-compiler    list available compilers (for --compiler option)
  [...]

When --help-compiler is seen on the command line, the function
'show_compilers()' would be called.  (Presumably this would really be
provided by the ccompiler module, since the same function would be
needed in three commands.)  This has to be a function object, not a
method (or method name), since the command class hasn't been
instantiated when we're just parsing the command line.

Presence of any --help option should terminate processing -- see the
code in 'parse_command_line()'.

Rene, can you whip up a patch for this?  Thanks!

        Greg
-- 
Greg Ward - nerd                                        gward@python.net
http://starship.python.net/~gward/
I guess it was all a DREAM ... or an episode of HAWAII FIVE-O ...