From b1cb27d34eb63e066273bb1c2b37199d51d23fb4 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 20 Jan 2018 17:05:07 +0530 Subject: [PATCH] Reduce classes with target_dir attribute --- src/pip/_internal/commands/install.py | 2 +- src/pip/_internal/req/req_install.py | 10 +++++----- src/pip/_internal/req/req_set.py | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index a86a1c9bf..4bfea8744 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -243,7 +243,6 @@ class InstallCommand(RequirementCommand): options.build_dir, delete=build_delete, kind="install" ) as directory: requirement_set = RequirementSet( - target_dir=target_temp_dir.path, pycompile=options.compile, require_hashes=options.require_hashes, ) @@ -294,6 +293,7 @@ class InstallCommand(RequirementCommand): install_options, global_options, root=options.root_path, + home=target_temp_dir.path, prefix=options.prefix_path, warn_script_location=options.warn_script_location, use_user_site=options.use_user_site, diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 7f72a1ba3..2136da3c9 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -120,7 +120,6 @@ class InstallRequirement(object): self.install_succeeded = None # UninstallPathSet of uninstalled distribution (for possible rollback) self.uninstalled_pathset = None - self.target_dir = None self.options = options if options else {} self.pycompile = pycompile # Set to True after successful preparation of this requirement @@ -730,7 +729,8 @@ class InstallRequirement(object): return True def install(self, install_options, global_options=None, root=None, - prefix=None, warn_script_location=True, use_user_site=False): + home=None, prefix=None, warn_script_location=True, + use_user_site=False): global_options = global_options if global_options is not None else [] if self.editable: self.install_editable( @@ -742,7 +742,7 @@ class InstallRequirement(object): wheel.check_compatibility(version, self.name) self.move_wheel_files( - self.source_dir, root=root, prefix=prefix, + self.source_dir, root=root, prefix=prefix, home=home, warn_script_location=warn_script_location, use_user_site=use_user_site, ) @@ -940,12 +940,12 @@ class InstallRequirement(object): def is_wheel(self): return self.link and self.link.is_wheel - def move_wheel_files(self, wheeldir, root=None, prefix=None, + def move_wheel_files(self, wheeldir, root=None, home=None, prefix=None, warn_script_location=True, use_user_site=False): move_wheel_files( self.name, self.req, wheeldir, user=use_user_site, - home=self.target_dir, + home=home, root=root, prefix=prefix, pycompile=self.pycompile, diff --git a/src/pip/_internal/req/req_set.py b/src/pip/_internal/req/req_set.py index b8c104c23..d6b0b9e5f 100644 --- a/src/pip/_internal/req/req_set.py +++ b/src/pip/_internal/req/req_set.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) class RequirementSet(object): def __init__(self, - require_hashes=False, target_dir=None, + require_hashes=False, pycompile=True): """Create a RequirementSet. @@ -29,7 +29,6 @@ class RequirementSet(object): self.unnamed_requirements = [] self.successfully_downloaded = [] self.reqs_to_cleanup = [] - self.target_dir = target_dir # set from --target option self.pycompile = pycompile # Maps from install_req -> dependencies_of_install_req self._dependencies = defaultdict(list) @@ -80,7 +79,6 @@ class RequirementSet(object): wheel.filename ) - install_req.target_dir = self.target_dir install_req.pycompile = self.pycompile install_req.is_direct = (parent_req_name is None)