From 8f758f12e22496d6ec51a8088681b22614d90bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Fri, 5 Jan 2018 22:31:44 +0100 Subject: [PATCH] zulip_bots setup.py: Install deps from the bots' requirements.txt files. This makes it straightforward to add dependencies for a bot, and works around https://github.com/pypa/pip/issues/4957. --- zulip_bots/setup.py | 15 ++++++--------- zulip_bots/zulip_bots/provision.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/zulip_bots/setup.py b/zulip_bots/setup.py index 2beccdeeb..c57a39665 100755 --- a/zulip_bots/setup.py +++ b/zulip_bots/setup.py @@ -10,6 +10,8 @@ import generate_manifest +from zulip_bots import provision + ZULIP_BOTS_VERSION = "0.3.9" IS_PYPA_PACKAGE = False @@ -48,15 +50,6 @@ setuptools_info = dict( install_requires=[ 'zulip', - 'mock>=2.0.0', - 'html2text', # for bots/define - 'BeautifulSoup4', # for bots/googlesearch - 'lxml', # for bots/googlesearch - 'requests', # for bots/link_shortener and bots/jira - 'python-chess[engine,gaviota]', # for bots/chess - 'wit', # for bots/witai - 'apiai', # for bots/dialogflow - 'simple_salesforce' # for bots/salesforce ], ) @@ -98,5 +91,9 @@ def check_dependency_manually(module_name, version=None): package_list.append('zulip_bots.bots.' + dir_name) package_info['packages'] = package_list +# Install all requirements for all bots. +bot_paths = provision.get_bot_paths() +for bot_path in bot_paths: + provision.provision_bot(path_to_bot=bot_path, force=False) setup(**package_info) diff --git a/zulip_bots/zulip_bots/provision.py b/zulip_bots/zulip_bots/provision.py index 2ebf69583..906e2a0a5 100755 --- a/zulip_bots/zulip_bots/provision.py +++ b/zulip_bots/zulip_bots/provision.py @@ -10,6 +10,13 @@ import pip from typing import Iterator +def get_bot_paths(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + bots_dir = os.path.join(current_dir, "bots") + bots_subdirs = map(lambda d: os.path.abspath(d), glob.glob(bots_dir + '/*')) + paths = filter(lambda d: os.path.isdir(d), bots_subdirs) + return paths + def provision_bot(path_to_bot, force): # type: (str, bool) -> None req_path = os.path.join(path_to_bot, 'requirements.txt') @@ -66,12 +73,7 @@ def parse_args(available_bots): def main(): # type: () -> None - current_dir = os.path.dirname(os.path.abspath(__file__)) - bots_dir = os.path.join(current_dir, "bots") - bots_subdirs = map(lambda d: os.path.abspath(d), glob.glob(bots_dir + '/*')) - available_bots = filter(lambda d: os.path.isdir(d), bots_subdirs) - - options = parse_args(available_bots) + options = parse_args(available_bots=get_bot_paths()) if not options.quiet: logging.basicConfig(stream=sys.stdout, level=logging.INFO)