Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/clean.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | d48fa0afdcba |
| children | a5229237eb50 a6d3930b5613 |
| rev | line source |
|---|---|
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1 """distutils.command.clean |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Implements the Distutils 'clean' command.""" |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
4 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
5 # contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
6 |
|
33965
893d46576737
Update compatibility comments to 2.1, corresponding to PEP 291 1.13.
Martin v. Löwis <martin@v.loewis.de>
parents:
26285
diff
changeset
|
7 # This module should be kept compatible with Python 2.1. |
|
26285
42bfc98d295b
Add comment to Distutil files about requiring 1.5.2 compatibility, as
Andrew M. Kuchling <amk@amk.ca>
parents:
23701
diff
changeset
|
8 |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
9 __revision__ = "$Id$" |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
10 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
11 import os |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
12 from distutils.core import Command |
|
13871
8307446bc6aa
Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents:
12785
diff
changeset
|
13 from distutils.dir_util import remove_tree |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15216
diff
changeset
|
14 from distutils import log |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
15 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
16 class clean (Command): |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
17 |
|
34648
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
18 description = "clean up temporary files from 'build' command" |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
19 user_options = [ |
| 12021 | 20 ('build-base=', 'b', |
| 21 "base build directory (default: 'build.build-base')"), | |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
22 ('build-lib=', None, |
| 12021 | 23 "build directory for all modules (default: 'build.build-lib')"), |
| 24 ('build-temp=', 't', | |
| 25 "temporary build directory (default: 'build.build-temp')"), | |
|
14517
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
26 ('build-scripts=', None, |
|
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
27 "build directory for scripts (default: 'build.build-scripts')"), |
|
12700
94ede04b9a9e
Rename 'build_bdist' to 'bdist_base', and get it by default from the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12699
diff
changeset
|
28 ('bdist-base=', None, |
|
12693
1dee93eb9ee3
Added the 'build_bdist' option and code to clean it up -- this is the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12021
diff
changeset
|
29 "temporary directory for built distributions"), |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
30 ('all', 'a', |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
31 "remove all build output, not just temporary by-products") |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
32 ] |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
33 |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14517
diff
changeset
|
34 boolean_options = ['all'] |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14517
diff
changeset
|
35 |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
36 def initialize_options(self): |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
37 self.build_base = None |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
38 self.build_lib = None |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
39 self.build_temp = None |
|
14517
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
40 self.build_scripts = None |
|
12700
94ede04b9a9e
Rename 'build_bdist' to 'bdist_base', and get it by default from the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12699
diff
changeset
|
41 self.bdist_base = None |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
42 self.all = None |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
43 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
44 def finalize_options(self): |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
45 self.set_undefined_options('build', |
|
12693
1dee93eb9ee3
Added the 'build_bdist' option and code to clean it up -- this is the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12021
diff
changeset
|
46 ('build_base', 'build_base'), |
|
1dee93eb9ee3
Added the 'build_bdist' option and code to clean it up -- this is the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12021
diff
changeset
|
47 ('build_lib', 'build_lib'), |
|
14517
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
48 ('build_scripts', 'build_scripts'), |
|
12700
94ede04b9a9e
Rename 'build_bdist' to 'bdist_base', and get it by default from the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12699
diff
changeset
|
49 ('build_temp', 'build_temp')) |
|
94ede04b9a9e
Rename 'build_bdist' to 'bdist_base', and get it by default from the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12699
diff
changeset
|
50 self.set_undefined_options('bdist', |
|
94ede04b9a9e
Rename 'build_bdist' to 'bdist_base', and get it by default from the
Gregory P. Smith <greg@mad-scientist.com>
parents:
12699
diff
changeset
|
51 ('bdist_base', 'bdist_base')) |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
52 |
|
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
53 def run(self): |
| 12021 | 54 # remove the build/temp.<plat> directory (unless it's already |
| 55 # gone) | |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
56 if os.path.exists(self.build_temp): |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15216
diff
changeset
|
57 remove_tree(self.build_temp, dry_run=self.dry_run) |
|
12785
f6e730f65bce
Moved warnings out of 'finalize_options()' into 'run()'.
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
58 else: |
|
23701
9a5c48579633
Change warning to debug level; it's a very minor issue.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
59 log.debug("'%s' does not exist -- can't clean it", |
|
9a5c48579633
Change warning to debug level; it's a very minor issue.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
60 self.build_temp) |
|
12785
f6e730f65bce
Moved warnings out of 'finalize_options()' into 'run()'.
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
61 |
|
12018
056972517191
Contribution from Bastian Kleineidam <calvin@cs.uni-sb.de>:
Greg Ward <gward@python.net>
parents:
diff
changeset
|
62 if self.all: |
|
14517
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
63 # remove build directories |
|
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
64 for directory in (self.build_lib, |
|
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
65 self.bdist_base, |
| 15216 | 66 self.build_scripts): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
67 if os.path.exists(directory): |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15216
diff
changeset
|
68 remove_tree(directory, dry_run=self.dry_run) |
|
14517
bf844ac2c81a
Bastian Kleineidam: fix so it cleans up the temporary script-building
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
69 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15216
diff
changeset
|
70 log.warn("'%s' does not exist -- can't clean it", |
|
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15216
diff
changeset
|
71 directory) |
| 12021 | 72 |
| 73 # just for the heck of it, try to remove the base build directory: | |
| 74 # we might have emptied it right now, but if not we don't care | |
| 75 if not self.dry_run: | |
| 76 try: | |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
77 os.rmdir(self.build_base) |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15216
diff
changeset
|
78 log.info("removing '%s'", self.build_base) |
| 12021 | 79 except OSError: |
| 80 pass | |
|
12743
e878a647e06e
Normalized all the end-of-class lines.
Greg Ward <gward@python.net>
parents:
12700
diff
changeset
|
81 |
|
e878a647e06e
Normalized all the end-of-class lines.
Greg Ward <gward@python.net>
parents:
12700
diff
changeset
|
82 # class clean |
