[ python-Bugs-818201 ] distutils: clean -b ignored; set_undefined_options doesn't

SourceForge.net noreply at sourceforge.net
Sat Jul 10 17:28:39 CEST 2004


Bugs item #818201, was opened at 2003-10-05 13:37
Message generated for change (Settings changed) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=818201&group_id=5470

Category: Distutils
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Nicholas Riley (nriley)
>Assigned to: Nobody/Anonymous (nobody)
Summary: distutils: clean -b ignored; set_undefined_options doesn't

Initial Comment:
I reported this on the distutils-sig list and didn't receive 
any response. I'd be happy to provide a patch, but I'm not 
sure which way to go.

<http://mail.python.org/pipermail/distutils-sig/2003-
September/003414.html>

Here's something that I think should work:

% python setup.py --help clean
[...]
Options for 'clean' command:
  --build-base (-b)  base build directory (default: 
'build.build-base')
% python setup.py clean -b ../builds
running clean

Nothing happens.  This works, however:

% python setup.py build -b ../builds clean
running build
running build_py
running build_ext
running config
gcc -E -I/Library/Frameworks/Python.framework/Versions/
2.3/include/python2.3 -o_configtest.i _configtest.c
removing: _configtest.c _configtest.i
running clean
removing '../builds/temp.darwin-6.8-Power_Macintosh-2.3' 
(and everything under it)

The logic to set build_temp from build_base (-b) is only 
present in the build command, not in the clean command.  
The code to set this option runs from 
clean.set_undefined_options.  But it's clean's build_base 
option which is set at the time, not build's, so it 
propagates an empty path.

The test command class I found posted to the distutils-sig 
mailing list has a workaround for the above problem, which 
looks like this:

    def finalize_options(self):
        build = self.distribution.get_command_obj('build')
        build_options = ('build_base', 'build_purelib', 
'build_platlib')
        for option in build_options:
            setattr(build, option, getattr(self, option))
        build.ensure_finalized()
        for option in build_options:
            setattr(self, option, getattr(build, option))

and doesn't call self.set_undefined_options at all, though 
the last three lines could be replaced by it.

There are several solutions I can think of:

- set_undefined_options should be changed to propagate 
set options to
  the source command object before calling 
src_cmd_obj.ensure_finalized.

- another method should be added to the cmd class, which 
does the above
  propagation then calls set_undefined_options.

- a workaround such as the one above should be placed in 
the
  distutils.command.clean.clean class.

Does this make sense?  Unless there's a huge compatibility 
issue, I'd favor the first option, but my experience with 
distutils is limited.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=818201&group_id=5470


More information about the Python-bugs-list mailing list