]> jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/setuptools/_distutils/command/clean.py
init: venv aand flask
[dlqueue.git] / venv / lib / python3.11 / site-packages / setuptools / _distutils / command / clean.py
1 """distutils.command.clean
2
3 Implements the Distutils 'clean' command."""
4
5 # contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
6
7 import os
8 from ..core import Command
9 from ..dir_util import remove_tree
10 from distutils._log import log
11
12
13 class clean(Command):
14 description = "clean up temporary files from 'build' command"
15 user_options = [
16 ('build-base=', 'b', "base build directory (default: 'build.build-base')"),
17 (
18 'build-lib=',
19 None,
20 "build directory for all modules (default: 'build.build-lib')",
21 ),
22 ('build-temp=', 't', "temporary build directory (default: 'build.build-temp')"),
23 (
24 'build-scripts=',
25 None,
26 "build directory for scripts (default: 'build.build-scripts')",
27 ),
28 ('bdist-base=', None, "temporary directory for built distributions"),
29 ('all', 'a', "remove all build output, not just temporary by-products"),
30 ]
31
32 boolean_options = ['all']
33
34 def initialize_options(self):
35 self.build_base = None
36 self.build_lib = None
37 self.build_temp = None
38 self.build_scripts = None
39 self.bdist_base = None
40 self.all = None
41
42 def finalize_options(self):
43 self.set_undefined_options(
44 'build',
45 ('build_base', 'build_base'),
46 ('build_lib', 'build_lib'),
47 ('build_scripts', 'build_scripts'),
48 ('build_temp', 'build_temp'),
49 )
50 self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
51
52 def run(self):
53 # remove the build/temp.<plat> directory (unless it's already
54 # gone)
55 if os.path.exists(self.build_temp):
56 remove_tree(self.build_temp, dry_run=self.dry_run)
57 else:
58 log.debug("'%s' does not exist -- can't clean it", self.build_temp)
59
60 if self.all:
61 # remove build directories
62 for directory in (self.build_lib, self.bdist_base, self.build_scripts):
63 if os.path.exists(directory):
64 remove_tree(directory, dry_run=self.dry_run)
65 else:
66 log.warning("'%s' does not exist -- can't clean it", directory)
67
68 # just for the heck of it, try to remove the base build directory:
69 # we might have emptied it right now, but if not we don't care
70 if not self.dry_run:
71 try:
72 os.rmdir(self.build_base)
73 log.info("removing '%s'", self.build_base)
74 except OSError:
75 pass