"""distutils.command.clean
Implements the Distutils 'clean' command."""
# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
# This module should be kept compatible with Python 2.1.
__revision__
= "$Id: clean.py,v 1.16 2004/11/10 22:23:15 loewis Exp $"
from distutils
.core
import Command
from distutils
.dir_util
import remove_tree
from distutils
import log
description
= "clean up output of 'build' command"
"base build directory (default: 'build.build-base')"),
"build directory for all modules (default: 'build.build-lib')"),
"temporary build directory (default: 'build.build-temp')"),
"build directory for scripts (default: 'build.build-scripts')"),
"temporary directory for built distributions"),
"remove all build output, not just temporary by-products")
boolean_options
= ['all']
def initialize_options(self
):
self
.build_scripts
= None
def finalize_options(self
):
self
.set_undefined_options('build',
('build_base', 'build_base'),
('build_lib', 'build_lib'),
('build_scripts', 'build_scripts'),
('build_temp', 'build_temp'))
self
.set_undefined_options('bdist',
('bdist_base', 'bdist_base'))
# remove the build/temp.<plat> directory (unless it's already
if os
.path
.exists(self
.build_temp
):
remove_tree(self
.build_temp
, dry_run
=self
.dry_run
)
log
.debug("'%s' does not exist -- can't clean it",
# remove build directories
for directory
in (self
.build_lib
,
if os
.path
.exists(directory
):
remove_tree(directory
, dry_run
=self
.dry_run
)
log
.warn("'%s' does not exist -- can't clean it",
# just for the heck of it, try to remove the base build directory:
# we might have emptied it right now, but if not we don't care
os
.rmdir(self
.build_base
)
log
.info("removing '%s'", self
.build_base
)