33import os .path
44
55
6- version_info = (0 , 0 , 2 )
6+ version_info = (0 , 0 , 3 )
77__version__ = '.' .join (str (v ) for v in version_info )
88
99
@@ -41,6 +41,8 @@ def initialize_options(self):
4141 self .dist = False
4242 self .eggs = False
4343 self .egg_base = None
44+ self .environment = False
45+ self .virtualenv_dir = None
4446
4547 def finalize_options (self ):
4648 _CleanCommand .finalize_options (self )
@@ -53,6 +55,9 @@ def finalize_options(self):
5355 if self .egg_base is None :
5456 self .egg_base = os .curdir
5557
58+ if self .environment and self .virtualenv_dir is None :
59+ self .virtualenv_dir = os .environ .get ('VIRTUAL_ENV' , None )
60+
5661 def run (self ):
5762 _CleanCommand .run (self )
5863
@@ -73,6 +78,9 @@ def run(self):
7378 if name .endswith ('.egg' ):
7479 dir_names .add (name )
7580
81+ if self .environment and self .virtualenv_dir :
82+ dir_names .add (self .virtualenv_dir )
83+
7684 for dir_name in dir_names :
7785 if os .path .exists (dir_name ):
7886 dir_util .remove_tree (dir_name , dry_run = self .dry_run )
@@ -101,12 +109,16 @@ def _set_options():
101109 CleanCommand .user_options .extend ([
102110 ('dist' , 'd' , 'remove distribution directory' ),
103111 ('eggs' , None , 'remove egg and egg-info directories' ),
112+ ('environment' , 'E' , 'remove virtual environment directory' ),
104113
105114 ('egg-base=' , 'e' ,
106115 'directory containing .egg-info directories '
107116 '(default: top of the source tree)' ),
117+ ('virtualenv-dir=' , None ,
118+ 'root directory for the virtual directory '
119+ '(default: value of VIRTUAL_ENV environment variable)' ),
108120 ])
109121 CleanCommand .boolean_options = _CleanCommand .boolean_options [:]
110- CleanCommand .boolean_options .extend (['dist' , 'eggs' ])
122+ CleanCommand .boolean_options .extend (['dist' , 'eggs' , 'environment' ])
111123
112124_set_options ()
0 commit comments