1 """distutils.command.clean
3 Implements the Distutils 'clean' command."""
5 # contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
10 from distutils
.core
import Command
11 from distutils
.util
import remove_tree
13 class clean (Command
):
15 description
= "clean up output of 'build' command"
18 "base build directory (default: 'build.build-base')"),
20 "build directory for all modules (default: 'build.build-lib')"),
22 "temporary build directory (default: 'build.build-temp')"),
24 "remove all build output, not just temporary by-products")
27 def initialize_options(self
):
28 self
.build_base
= None
30 self
.build_temp
= None
33 def finalize_options(self
):
34 if self
.build_lib
and not os
.path
.exists (self
.build_lib
):
35 self
.warn ("'%s' does not exist -- can't clean it" %
37 if self
.build_temp
and not os
.path
.exists (self
.build_temp
):
38 self
.warn ("'%s' does not exist -- can't clean it" %
41 self
.set_undefined_options('build',
42 ('build_base', 'build_base'),
43 ('build_lib', 'build_lib'),
44 ('build_temp', 'build_temp'))
47 # remove the build/temp.<plat> directory (unless it's already
49 if os
.path
.exists (self
.build_temp
):
50 remove_tree (self
.build_temp
, self
.verbose
, self
.dry_run
)
53 # remove the module build directory (unless already gone)
54 if os
.path
.exists (self
.build_lib
):
55 remove_tree (self
.build_lib
, self
.verbose
, self
.dry_run
)
57 # just for the heck of it, try to remove the base build directory:
58 # we might have emptied it right now, but if not we don't care
61 os
.rmdir (self
.build_base
)
62 self
.announce ("removing '%s'" % self
.build_base
)