[Distutils] Re: Opening up backdoors to 'setup()'

Amos Latteier amos@digicool.com
Mon, 28 Aug 2000 10:29:27 -0700

Greg Ward wrote:
> Hi all --
> in the last couple of weeks, two people (Amos Latteier & Paul Dubois, to
> be specific) have asked about better programmatic access to the
> 'setup()' function.  The two cases are sort of opposite but closely
> related:
> In both cases, what's needed is a bit of "backdoor" access that skirts
> around the usual convention: setup script encodes useful information in
> keyword arguments, which are then passed into the guts of the Distutils
> by calling 'setup()'.

I've thought about this a little. It seems to me that the basic desire
is to be able to run setup from python, not the command line. I think we
could accommodate this with something like this

  distutils.core.run_setup(file, commands)

This would return the results of running the named setup file with the
given commands. I don't really care about how you spell the file and the
commands. For example, perhaps file should be an open file object rather
than a path, and maybe commands is a list of strings instead of a
string. Whatever ;-)

This facility seems relatively easy to understand and implement. And I
believe that it accomplishes most of what Paul and I want. 

The remaining problem is that most commands don't return anything, they
just print information. This means that when you run a command on a
setup file from python, it won't be easy to figure out whether it worked
or not.

I haven't looked at the commands very much but perhaps they could be
retrofitted to return something in addition to printing information.
Otherwise there could be new commands that were meant to be called from
python. Or failing that you could capture the stdout and try to deduce
from there how things went.

In my case I'll probably write a new command called something like
'metadata' that doesn't do anything but return meta-data about the

This would allow me to do something like this:

  meta_data=distutils.core.run_setup(open('foo-1.0.tgz'), 'metadata')

which is what I want.


Amos Latteier         mailto:amos@digicool.com
Digital Creations     http://www.digicool.com