Bug 1306691 - Remove install_method argument and uses; r?ted draft
authorGregory Szorc <gps@mozilla.com>
Fri, 30 Sep 2016 12:20:13 -0700
changeset 419668 5c4ca3ca59ed1593f28015d930d7e99e4b82dd19
parent 419667 6b8191a1e430be904ee68504fc3270865ae8228e
child 532629 f24980513d80a18674ce8455e8bc5546b59d22f5
push id30991
push userbmo:gps@mozilla.com
push dateFri, 30 Sep 2016 19:22:21 +0000
reviewersted
bugs1306691
milestone52.0a1
Bug 1306691 - Remove install_method argument and uses; r?ted Now that we've removed support for using easy_install, we no longer need the "install_method" argument to specify how we want to install packages since there is only one method: pip. So remove that code. MozReview-Commit-ID: BmjerQtfHov
testing/mozharness/mozharness/base/python.py
--- a/testing/mozharness/mozharness/base/python.py
+++ b/testing/mozharness/mozharness/base/python.py
@@ -194,17 +194,17 @@ class VirtualenvMixin(object):
 
     def is_python_package_installed(self, package_name, error_level=WARNING):
         """
         Return whether the package is installed
         """
         packages = self.package_versions(error_level=error_level).keys()
         return package_name.lower() in [package.lower() for package in packages]
 
-    def install_module(self, module=None, module_url=None, install_method=None,
+    def install_module(self, module=None, module_url=None,
                        requirements=(), optional=False, global_options=[],
                        no_deps=False, editable=False):
         """
         Install module via pip.
 
         module_url can be a url to a python package tarball, a path to
         a directory containing a setup.py (absolute or relative to work_dir)
         or None, in which case it will default to the module name.
@@ -216,37 +216,35 @@ class VirtualenvMixin(object):
         """
         c = self.config
         dirs = self.query_abs_dirs()
         env = self.query_env()
         venv_path = self.query_virtualenv_path()
         self.info("Installing %s into virtualenv %s" % (module, venv_path))
         if not module_url:
             module_url = module
-        if install_method in (None, 'pip'):
-            if not module_url and not requirements:
-                self.fatal("Must specify module and/or requirements")
-            pip = self.query_python_path("pip")
-            if c.get("verbose_pip"):
-                command = [pip, "-v", "install"]
-            else:
-                command = [pip, "install"]
-            if no_deps:
-                command += ["--no-deps"]
-            # To avoid timeouts with our pypi server, increase default timeout:
-            # https://bugzilla.mozilla.org/show_bug.cgi?id=1007230#c802
-            command += ['--timeout', str(c.get('pip_timeout', 120))]
-            for requirement in requirements:
-                command += ["-r", requirement]
-            if c.get('find_links') and not c["pip_index"]:
-                command += ['--no-index']
-            for opt in global_options:
-                command += ["--global-option", opt]
+
+        if not module_url and not requirements:
+            self.fatal("Must specify module and/or requirements")
+        pip = self.query_python_path("pip")
+        if c.get("verbose_pip"):
+            command = [pip, "-v", "install"]
         else:
-            self.fatal("install_module() doesn't understand an install_method of %s!" % install_method)
+            command = [pip, "install"]
+        if no_deps:
+            command += ["--no-deps"]
+        # To avoid timeouts with our pypi server, increase default timeout:
+        # https://bugzilla.mozilla.org/show_bug.cgi?id=1007230#c802
+        command += ['--timeout', str(c.get('pip_timeout', 120))]
+        for requirement in requirements:
+            command += ["-r", requirement]
+        if c.get('find_links') and not c["pip_index"]:
+            command += ['--no-index']
+        for opt in global_options:
+            command += ["--global-option", opt]
 
         # Add --find-links pages to look at. Add --trusted-host automatically if
         # the host isn't secure. This allows modern versions of pip to connect
         # without requiring an override.
         proxxy = Proxxy(self.config, self.log_obj)
         trusted_hosts = set()
         for link in proxxy.get_proxies_and_urls(c.get('find_links', [])):
             parsed = urlparse.urlparse(link)
@@ -264,20 +262,17 @@ class VirtualenvMixin(object):
 
         if self.pip_version >= distutils.version.LooseVersion('6.0'):
             for host in sorted(trusted_hosts):
                 command.extend(['--trusted-host', host])
 
         # module_url can be None if only specifying requirements files
         if module_url:
             if editable:
-                if install_method in (None, 'pip'):
-                    command += ['-e']
-                else:
-                    self.fatal("editable installs not supported for install_method %s" % install_method)
+                command += ['-e']
             command += [module_url]
 
         # If we're only installing a single requirements file, use
         # the file's directory as cwd, so relative paths work correctly.
         cwd = dirs['abs_work_dir']
         if not module and len(requirements) == 1:
             cwd = os.path.dirname(requirements[0])
 
@@ -421,50 +416,47 @@ class VirtualenvMixin(object):
         pip_version = words[1]
         self.pip_version = distutils.version.LooseVersion(pip_version)
 
         if not modules:
             modules = c.get('virtualenv_modules', [])
         if not requirements:
             requirements = c.get('virtualenv_requirements', [])
         if not modules and requirements:
-            self.install_module(requirements=requirements,
-                                install_method='pip')
+            self.install_module(requirements=requirements)
         for module in modules:
             module_url = module
             global_options = []
             if isinstance(module, dict):
                 if module.get('name', None):
                     module_name = module['name']
                 else:
                     self.fatal("Can't install module without module name: %s" %
                                str(module))
                 module_url = module.get('url', None)
                 global_options = module.get('global_options', [])
             else:
                 module_url = self.config.get('%s_url' % module, module_url)
                 module_name = module
-            install_method = 'pip'
             self.install_module(module=module_name,
                                 module_url=module_url,
-                                install_method=install_method,
                                 requirements=requirements,
                                 global_options=global_options)
 
         for module, url, method, requirements, optional, two_pass, editable in \
                 self._virtualenv_modules:
             if two_pass:
                 self.install_module(
                     module=module, module_url=url,
-                    install_method=method, requirements=requirements or (),
+                    requirements=requirements or (),
                     optional=optional, no_deps=True, editable=editable
                 )
             self.install_module(
                 module=module, module_url=url,
-                install_method=method, requirements=requirements or (),
+                requirements=requirements or (),
                 optional=optional, editable=editable
             )
 
         self.info("Done creating virtualenv %s." % venv_path)
 
         self.package_versions(log_output=True)
 
     def activate_virtualenv(self):