[Distutils] Improving distutils vs redesigning it (was people want CPAN)

David Cournapeau cournape at gmail.com
Thu Nov 12 13:57:27 CET 2009

On Thu, Nov 12, 2009 at 8:14 PM, Tarek Ziadé <ziade.tarek at gmail.com> wrote:

> Now, there's no reason at all that we can''t add an API in
> distutils.util for example, that let you get
> the build paths, and that will be used by all build_ commands, so you
> don't have to use a build_ command
> to get them.
> I propose that you think about its signature, and that I add it after
> we agree on it.

The signature does not really matter I think. Since those parameters
depends on user customization (through config files or command line
flags), it could be something like:

class FinalizedOptions:
    def get_build_dir_library(self):

    def get_build_dir_src(self):

    def get_prefix(self):


And a function like

def get_finalized_options():
    # compute the finalized options
    # Cache it if expensive
    return FinalizedOptions()

could be used to obtain those options.

what  really matters is:
   - it should be callable from anywhere, at any time: inside
setup.py, in any commands, etc...
   - ideally, it should work for any python >= 2.4 (not every python
version have the exact same conventions IIRC).

> by calling "get_paths(scheme, vars)", where scheme is the installation
> scheme you want (unix, nt, etc)
> and vars your variables if you want to override any $VARIABLE.

Assuming the above FinalizedOptions is available, I could obtain the
needed options.

> You mean, accessing other commands command line options ? or the result
> of their finalizations ?

The result after finalization.

> For me, the install_cmd <-> build_clib problem shows that the "install" command
> do some work that is needed by other commands, and that this work has
> to be taken
> out of it.
> A command performs something, and should not be used to set up an *environment*.

I am not sure I understand *environment* in that context. If you mean
options, then each command has its set of options, and yes, that's one
of the fundamental issue I often complain about in distutils. The
build_clib/install interaction I described is typical, and we do this
kind of stuff in pretty much every command.

> Do you agree that this change will help you, and is possible without
> replacing Distutils ?

It would definitely be helpful to get access to any finalized command
option from anywhere at anytime, especially if it is supported for all
the python versions we support (2.4 and above - I don't know what
version distribute intends to support).

Ideally, it would solve a fair shair amount of issues if this was done
at the UI level as well, that is something like

python setup.py build --compiler=mingw -> use mingw compiler for every
compiled code

But that's one of the thing which does not make much sense changing in
distutils, though: it would break almost anyone's workflow.


More information about the Distutils-SIG mailing list