From 3c53c36c21f2d63067c5363023a03b87b6f2f069 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 9c0e4ce..cf3a584 100644 --- a/zulip_bots/setup.py +++ b/zulip_bots/setup.py @@ -6,7 +6,7 @@ from __future__ import print_function import os import sys import glob -import pip +import subprocess if False: from typing import Any, Dict, Optional @@ -105,4 +105,5 @@ bots_subdirs = map(lambda d: os.path.abspath(d), glob.glob(bots_dir + '/*')) 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'])