[Distutils] Patch for new install options

Greg Ward gward@ase.com
Wed, 26 Apr 2000 21:27:14 -0400


[my proposed solution to the "fake install" problem]
>     ./setup.py -n install \
>       --prefix='/tmp$sys_prefix' --exec-prefix='/tmp$sys_exec_prefix'

[Harry begs to differ]
> While this works perfectly fine, my problems with it is that it is not
> pretty and it presupposes that someone reading the spec file has some
> knowledge of the internal operations of  Distutils. It is even uglier as
> it will appear in an actual spec file (I'm not sure why the above is a dry
> run, so I left the -n off of this example): 
> 
> ./setup.py install --prefix=$RPM_BUILD_ROOT'$sys_prefix' \
>   --exec-prefix=$RPM_BUILD_ROOT'$sys_exec_prefix'
> 
> Compare this with:
> 
> ./setup.py install --package-prefix=$RPM_BUILD_ROOT

Hmmm, you have a point.  When generating built distributions, you really 
do want to sneak a new root directory into the installation paths.  So
how about this minor spelling change:

    ./setup.py install --root=$RPM_BUILD_ROOT

and, instead of having a new artifical "unix_package_prefix" scheme
(BTW, *that's* what I was calling artificial, not the idea of a --root
or --package-prefix option), a little bit of code somewhere in
'finalize_options()' would do this:

    if self.root is not None:
        for attr in ('install_lib', 'install_scripts', ...):
            setattr (self, attr,
                     os.path.join (self.root, getattr (self, attr)))

This would have to be pretty late in the game: after expanding all
config vars, after setting 'install_lib', and after
'handle_extra_path()'.

So yeah, we would have yet another kind of "base directory", which still
bothers me a little bit.  However, it would only be needed for
generating built distributions, and use of it would usually be buried
inside one of the bdist_* commands... so I guess I can live with it.

I'm going to have to think about how to fix/simplify the 'bdist_dumb'
command now -- it does a lot of this stuff on its own, and it probably
should be done by the "install" command.  One useful side-effect is that 
this will fix the bug whereby .pth files don't get included in built
distributions, since the mock install is done by the "install" command,
as it should be.

Yeah, OK, I'm starting to like this.  Grudgingly.  ;-)

        Greg

PS. using "--prefix='/tmp$sys_prefix'" won't require knowledge of
Distutils internals, since the configuration variables will be a
documented part of the interface.  I admit that it's still a tricky and
specialized part of the interface though, and it would be best to
restrict config vars to the config file if at all possible.  It just
seems bogus to *disallow* them from the command line when they might be
useful, hence last night's hack.  Err, patch.

-- 
Greg Ward - programmer-at-large                         gward@python.net
http://starship.python.net/~gward/
UFO's are for real: the Air Force doesn't exist.