From d7aae66886afbd32f4eee73c57d58c11544be96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 11 Jan 2019 14:23:48 +0100 Subject: [PATCH] Add --disable-pip-version-check to pip calls Users get too confused by the warning the lack of it generates on plugin installs/uninstalls and updates of any kind through pip. An FAQ entry on that matter hasn't helped, so we are now pulling out the nuclear option to reduce support overhead. Implements #2988 --- src/octoprint/plugins/pluginmanager/__init__.py | 4 ++-- src/octoprint/plugins/softwareupdate/updaters/pip.py | 2 +- src/octoprint/util/pip.py | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index c085c032e..f6c492fdf 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -363,7 +363,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin, raise ValueError("Either URL or path must be provided") self._logger.info("Installing plugin from {}".format(source)) - pip_args = ["install", sarge.shell_quote(source), '--no-cache-dir'] + pip_args = ["--disable-pip-version-check", "install", sarge.shell_quote(source), "--no-cache-dir"] if dependency_links or self._settings.get_boolean(["dependency_links"]): pip_args.append("--process-dependency-links") @@ -521,7 +521,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin, if origin is None: origin = plugin.origin[2] - pip_args = ["uninstall", "--yes", origin] + pip_args = ["--disable-pip-version-check", "uninstall", "--yes", origin] try: self._call_pip(pip_args) except: diff --git a/src/octoprint/plugins/softwareupdate/updaters/pip.py b/src/octoprint/plugins/softwareupdate/updaters/pip.py index fb970144f..ef4101681 100644 --- a/src/octoprint/plugins/softwareupdate/updaters/pip.py +++ b/src/octoprint/plugins/softwareupdate/updaters/pip.py @@ -86,7 +86,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc install_arg = check["pip"].format(target_version=target_version, target=target_version) logger.debug(u"Target: %s, executing pip install %s" % (target, install_arg)) - pip_args = ["install", install_arg, "--no-cache-dir"] + pip_args = ["--disable-pip-version-check", "install", install_arg, "--no-cache-dir"] pip_kwargs = dict() if pip_working_directory is not None: pip_kwargs.update(cwd=pip_working_directory) diff --git a/src/octoprint/util/pip.py b/src/octoprint/util/pip.py index 77052c48c..31564bdf9 100644 --- a/src/octoprint/util/pip.py +++ b/src/octoprint/util/pip.py @@ -27,6 +27,7 @@ class UnknownPip(Exception): class PipCaller(CommandlineCaller): process_dependency_links = pkg_resources.Requirement.parse("pip>=1.5") no_cache_dir = pkg_resources.Requirement.parse("pip>=1.6") + disable_pip_version_check = pkg_resources.Requirement.parse("pip>=6.0") no_use_wheel = pkg_resources.Requirement.parse("pip==1.5.0") broken = pkg_resources.Requirement.parse("pip>=6.0.1,<=6.0.3") @@ -47,6 +48,11 @@ class PipCaller(CommandlineCaller): logger.debug("Found --no-cache-dir flag, version {} doesn't support that yet though, removing.".format(pip_version)) args.remove("--no-cache-dir") + # strip --disable-pip-version-check for versions that don't support it + if not pip_version in cls.disable_pip_version_check and "--disable-pip-version-check" in args: + logger.debug("Found --disable-pip-version-check flag, version {} doesn't support that yet though, removing.".format(pip_version)) + args.remove("--disable-pip-version-check") + # add --no-use-wheel for versions that otherwise break if pip_version in cls.no_use_wheel and not "--no-use-wheel" in args: logger.debug("Version {} needs --no-use-wheel to properly work.".format(pip_version))