From f10bfa67ca920e4b726e2acf6dd1cf550c320b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 22 Mar 2018 13:59:38 +0100 Subject: [PATCH] Use "import pip" method of calling pip only as last resort Doing that poses too much risk with pip's general "no API support", as seen in #2499. --- src/octoprint/util/pip.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/octoprint/util/pip.py b/src/octoprint/util/pip.py index 7afbad272..724106ae8 100644 --- a/src/octoprint/util/pip.py +++ b/src/octoprint/util/pip.py @@ -11,6 +11,7 @@ import sys import logging import site import threading +import os import pkg_resources @@ -237,6 +238,10 @@ class PipCaller(CommandlineCaller): @classmethod def autodetect_pip(cls): commands = [[sys.executable, "-m", "pip"], + [os.path.join(os.path.dirname(sys.executable), "pip.exe" if sys.platform == "win32" else "pip")], + + # this should be our last resort since it might fail thanks to using pip programmatically like + # that is not officially supported or sanctioned by the pip developers [sys.executable, "-c", "import sys; sys.argv = ['pip'] + sys.argv[1:]; import pip; pip.main()"]] for command in commands: