@@ -181,24 +181,34 @@ def remove_cache_items(self, options, args):
181
181
182
182
files = self ._find_wheels (options , args [0 ])
183
183
184
- # Only fetch http files if no specific pattern given
185
- if args [0 ] == '*' :
186
- files += self ._find_http_files (options )
187
-
188
184
if not files :
189
185
raise CommandError ('No matching packages' )
190
186
191
187
for filename in files :
192
188
os .unlink (filename )
193
189
logger .debug ('Removed %s' , filename )
190
+
191
+ dirs = filesystem .list_empty_subdirs (self ._cache_dir (options , 'http' )) + \
192
+ filesystem .list_empty_subdirs (self ._cache_dir (options , 'wheels' ))
193
+ for dirname in dirs :
194
+ os .rmdir (dirname )
195
+
194
196
logger .info ('Files removed: %s' , len (files ))
197
+ logger .info ('Empty directories removed: %s' , len (dirs ))
195
198
196
199
def purge_cache (self , options , args ):
197
200
# type: (Values, List[Any]) -> None
198
201
if args :
199
202
raise CommandError ('Too many arguments' )
200
203
201
- return self .remove_cache_items (options , ['*' ])
204
+ # Remove everything in the "http" and "wheels" cache directories.
205
+ filesystem .remove_subdirs (self ._cache_dir (options , 'http' ))
206
+ filesystem .remove_subdirs (self ._cache_dir (options , 'wheels' ))
207
+
208
+ # selfcheck.json is no longer used by pip.
209
+ selfcheck_json = self ._cache_dir (options , 'selfcheck.json' )
210
+ if os .path .isfile (selfcheck_json ):
211
+ os .remove (selfcheck_json )
202
212
203
213
def _cache_dir (self , options , subdir ):
204
214
# type: (Values, str) -> str
0 commit comments