提交 da1870b2 编写于 作者: A Alexandre Conrad

merge

......@@ -41,6 +41,7 @@ News for pip
download and installation into two steps. Thanks Simon Cross.
* Fix uninstalling from requirements file containing -f, -i, or
--extra-index-url.
* Leftover build directories are now removed. Thanks Alexandre Conrad.
0.6.3
-----
......
......@@ -158,7 +158,7 @@ class InstallCommand(Command):
for req in parse_requirements(filename, finder=finder, options=options):
requirement_set.add_requirement(req)
if not options.no_download:
requirement_set.install_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
else:
requirement_set.locate_files()
if not options.no_install and not self.bundle:
......@@ -172,6 +172,7 @@ class InstallCommand(Command):
requirement_set.successfully_downloaded])
if downloaded:
logger.notify('Successfully downloaded %s' % downloaded)
requirement_set.cleanup_files(bundle=self.bundle)
return requirement_set
InstallCommand()
......@@ -716,6 +716,7 @@ class RequirementSet(object):
self.ignore_dependencies = ignore_dependencies
self.successfully_downloaded = []
self.successfully_installed = []
self.reqs_to_cleanup = []
def __str__(self):
reqs = [req for req in self.requirements.values()
......@@ -806,7 +807,8 @@ class RequirementSet(object):
'an equivalent install with --no-install?)'
% (req_to_install, req_to_install.source_dir))
def install_files(self, finder, force_root_egg_info=False, bundle=False):
def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
"""Prepare process. Create temp directories, download and/or unpack files."""
unnamed = list(self.unnamed_requirements)
reqs = self.requirements.values()
while reqs or unnamed:
......@@ -835,8 +837,8 @@ class RequirementSet(object):
else:
logger.notify('Downloading/unpacking %s' % req_to_install)
logger.indent += 2
is_bundle = False
try:
is_bundle = False
if req_to_install.editable:
if req_to_install.source_dir is None:
location = req_to_install.build_location(self.src_dir)
......@@ -927,7 +929,7 @@ class RequirementSet(object):
if req_to_install.name not in self.requirements:
self.requirements[req_to_install.name] = req_to_install
else:
req_to_install.remove_temporary_source()
self.reqs_to_cleanup.append(req_to_install)
if install:
self.successfully_downloaded.append(req_to_install)
if bundle and (req_to_install.url and req_to_install.url.startswith('file:///')):
......@@ -935,6 +937,24 @@ class RequirementSet(object):
finally:
logger.indent -= 2
def cleanup_files(self, bundle=False):
"""Clean up files, remove builds."""
logger.notify('Cleaning up...')
logger.indent += 2
for req in self.reqs_to_cleanup:
req.remove_temporary_source()
try:
# create_bundle() is responsible for removing build_dir and
# src_dir after compression. create_bundle() is ran afterwards.
if not bundle:
for directory in self.build_dir,:
if not os.path.exists(directory):
continue
logger.info('Removing %s...' % directory)
os.rmdir(directory)
finally:
logger.indent -= 2
def copy_to_builddir(self, req_to_install):
target_dir = req_to_install.editable and self.src_dir or self.build_dir
logger.info("Copying %s to %s" %(req_to_install.name, target_dir))
......
from os.path import abspath, join, dirname, curdir, pardir
from os.path import abspath, exists, join, dirname, curdir, pardir
from test_pip import here, reset_env, run_pip, pyversion, lib_py, mkdir
def test_correct_pip_version():
......@@ -253,3 +253,14 @@ def test_install_pardir():
result = run_pip('install', pardir, cwd=run_from, expect_error=False)
assert (lib_py + 'site-packages/fspkg') in result.files_created, str(result.stdout)
assert (lib_py + 'site-packages/FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)
def test_cleanup():
"""
Test clean up of build directory after an install.
"""
reset_env()
# FIXME: We may want to test more scenarios
result = run_pip('install', 'INITools==dev', expect_error=False)
build = join(here, "test-scratch", "build")
assert not exists(build), "build dir still exists: %s" % build
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册