From 532fe753e14176eb92b2a62da2456eb4fcadbafb Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Sun, 15 Apr 2018 15:44:40 +0530 Subject: [PATCH] tools: Call pip from a sub-process instead of importing it The pip documentation recommends calling pip using a subprocess, instead of importing it and using it's internal API. The API of pip==10.0.0 is different from that of older versions, and provisioning is broken with this version. [pip docs]: https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program Closes #370 --- zulip_bots/setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zulip_bots/setup.py b/zulip_bots/setup.py index 9c0e4cebd..cf3a5845a 100644 --- a/zulip_bots/setup.py +++ b/zulip_bots/setup.py @@ -6,7 +6,7 @@ import os import sys import glob -import pip +import subprocess if False: from typing import Any, Dict, Optional @@ -105,4 +105,5 @@ def check_dependency_manually(module_name, version=None): bot_paths = filter(lambda d: os.path.isdir(d), bots_subdirs) for bot_path in bot_paths: req_path = os.path.join(bot_path, 'requirements.txt') - rcode = pip.main(['install', '-r', req_path, '--quiet']) + if os.path.exists(req_path): + subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', req_path, '--quiet'])