Fix deletion of temp dir when exception occurs
@@ -269,6 +269,7 @@ class InstallCommand(RequirementCommand):
# Create a target directory for using with the target option
target_temp_dir = TempDirectory(kind="target")
target_temp_dir_path = target_temp_dir.path
+ self.enter_context(target_temp_dir)
global_options = options.global_options or []
@@ -452,7 +453,6 @@ class InstallCommand(RequirementCommand):
# packages to be moved to target directory
lib_dir_list = []
- with target_temp_dir:
# Checking both purelib and platlib directories for installed
# packages to be moved to target directory
scheme = distutils_scheme('', home=target_temp_dir.path)
