Skip to content

Commit

Permalink
Delete cached requirements en mass
Browse files Browse the repository at this point in the history
Currently we delete succesfully installed requirements and not ones
that failed. Then (most of the time) we delete the requirements cache
that contained them, deleting everything. This means that useful
debugging context is lost (when we don't delete the cache), and we've
got complexity serving no point. Instead, either keep everything or
delete it all.
  • Loading branch information
rbtcollins committed May 5, 2015
1 parent 6872634 commit 470207f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
6 changes: 1 addition & 5 deletions pip/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,8 @@ def run(self, options, args):
'Successfully downloaded %s', downloaded
)
except PreviousBuildDirError:
options.no_clean = True
req_cache.delete = False
raise
finally:
# Clean up
if not options.no_clean:
requirement_set.cleanup_files()

if options.target_dir:
ensure_dir(options.target_dir)
Expand Down
5 changes: 1 addition & 4 deletions pip/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,5 @@ def run(self, options, args):
"Failed to build one or more wheels"
)
except PreviousBuildDirError:
options.no_clean = True
req_cache.delete = False
raise
finally:
if not options.no_clean:
requirement_set.cleanup_files()
5 changes: 5 additions & 0 deletions pip/req/req_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import

from collections import defaultdict
import logging
import os.path
import shutil
import tempfile
Expand All @@ -9,6 +10,9 @@
from pip.utils import display_path, ensure_dir, rmtree, _make_build_dir


logger = logging.getLogger(__name__)


class RequirementCache(object):
"""A cache of requirements.
Expand Down Expand Up @@ -77,6 +81,7 @@ def __exit__(self, exc, value, tb):

def cleanup(self):
if self.delete:
logger.debug('Cleaning up...')
rmtree(self.path)
self.path = None
self._urls = None
Expand Down
11 changes: 0 additions & 11 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def __init__(self, req_cache, download_dir, upgrade=False,
self.ignore_dependencies = ignore_dependencies
self.successfully_downloaded = []
self.successfully_installed = []
self.reqs_to_cleanup = []
self.as_egg = as_egg
self.use_user_site = use_user_site
self.target_dir = target_dir # set from --target option
Expand Down Expand Up @@ -535,9 +534,6 @@ def add_req(subreq):
for subreq in dist.requires(available_requested):
add_req(subreq)

# cleanup tmp src
self.reqs_to_cleanup.append(req_to_install)

if not req_to_install.editable and not req_to_install.satisfied_by:
# XXX: --no-install leads this to report 'Successfully
# downloaded' for only non-editable reqs, even though we took
Expand All @@ -546,13 +542,6 @@ def add_req(subreq):

return more_reqs

def cleanup_files(self):
"""Clean up files, remove builds."""
logger.debug('Cleaning up...')
with indent_log():
for req in self.reqs_to_cleanup:
req.remove_temporary_source()

def _to_install(self):
"""Create the installation order.
Expand Down

0 comments on commit 470207f

Please sign in to comment.