From a7ec58330cce153ed239baf3ca0bbdd596abcae1 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Thu, 5 Apr 2018 16:39:32 +0300 Subject: [PATCH] PY-29395 Use pip._internal.main instead of pip.main in pip 10.0 It's obviously only a workaround, we should find a better way not to use internal modules of the package altogether. --- python/helpers/packaging_tool.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/python/helpers/packaging_tool.py b/python/helpers/packaging_tool.py index e770cf41f671..165010252c6c 100644 --- a/python/helpers/packaging_tool.py +++ b/python/helpers/packaging_tool.py @@ -101,20 +101,27 @@ def do_get_latest_version(urls, req): return return "" + def do_install(pkgs): - try: - import pip - except ImportError: - error_no_pip() - return pip.main(['install'] + pkgs) + return pip_main(['install'] + pkgs) def do_uninstall(pkgs): + return pip_main(['uninstall', '-y'] + pkgs) + + +def pip_main(args): try: import pip except ImportError: error_no_pip() - return pip.main(['uninstall', '-y'] + pkgs) + + try: + func = pip.main + except AttributeError: + from pip._internal import main as func + + func(args) def do_pyvenv(path, system_site_packages):