2017-07-18 00:17:16 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-09-20 19:02:43 -04:00
|
|
|
import os
|
2017-07-18 00:17:16 -04:00
|
|
|
import sys
|
2017-10-11 01:53:13 -04:00
|
|
|
if False:
|
|
|
|
from typing import Any, Dict, Optional
|
2017-07-18 00:17:16 -04:00
|
|
|
|
2017-08-16 12:45:00 -04:00
|
|
|
import generate_manifest
|
|
|
|
|
2017-11-28 23:53:12 -05:00
|
|
|
ZULIP_BOTS_VERSION = "0.3.9"
|
2017-09-18 20:04:03 -04:00
|
|
|
IS_PYPA_PACKAGE = False
|
2017-09-20 19:02:43 -04:00
|
|
|
|
2017-09-18 20:04:03 -04:00
|
|
|
# IS_PYPA_PACKAGE is set to True by tools/release-packages
|
|
|
|
# before making a PyPA release.
|
|
|
|
if not IS_PYPA_PACKAGE:
|
|
|
|
generate_manifest.generate_dev_manifest()
|
2017-09-20 19:02:43 -04:00
|
|
|
|
2017-07-18 00:17:16 -04:00
|
|
|
# We should be installable with either setuptools or distutils.
|
|
|
|
package_info = dict(
|
|
|
|
name='zulip_bots',
|
2017-09-20 19:02:43 -04:00
|
|
|
version=ZULIP_BOTS_VERSION,
|
2017-07-18 00:17:16 -04:00
|
|
|
description='Zulip\'s Bot framework',
|
|
|
|
author='Zulip Open Source Project',
|
|
|
|
author_email='zulip-devel@googlegroups.com',
|
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 4 - Beta',
|
|
|
|
'Environment :: Web Environment',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Topic :: Communications :: Chat',
|
|
|
|
],
|
|
|
|
url='https://www.zulip.org/',
|
|
|
|
entry_points={
|
|
|
|
'console_scripts': [
|
|
|
|
'zulip-run-bot=zulip_bots.run:main',
|
2017-11-28 11:44:39 -05:00
|
|
|
'zulip-terminal=zulip_bots.terminal:main'
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
|
|
|
},
|
|
|
|
include_package_data=True,
|
2017-09-20 00:12:40 -04:00
|
|
|
cmdclass={
|
|
|
|
'gen_manifest': generate_manifest.GenerateManifest,
|
|
|
|
},
|
2017-07-18 00:17:16 -04:00
|
|
|
) # type: Dict[str, Any]
|
|
|
|
|
|
|
|
setuptools_info = dict(
|
|
|
|
install_requires=[
|
2017-09-20 19:02:43 -04:00
|
|
|
'zulip',
|
2017-07-18 00:17:16 -04:00
|
|
|
'mock>=2.0.0',
|
|
|
|
'html2text', # for bots/define
|
2017-11-30 11:52:45 -05:00
|
|
|
'BeautifulSoup4', # for bots/googlesearch
|
|
|
|
'lxml', # for bots/googlesearch
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
from setuptools import setup, find_packages
|
|
|
|
package_info.update(setuptools_info)
|
|
|
|
package_info['packages'] = find_packages()
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.version import LooseVersion
|
|
|
|
from importlib import import_module
|
|
|
|
|
|
|
|
# Manual dependency check
|
|
|
|
def check_dependency_manually(module_name, version=None):
|
2017-10-11 01:53:13 -04:00
|
|
|
# type: (str, Optional[str]) -> None
|
2017-07-18 00:17:16 -04:00
|
|
|
try:
|
2017-10-11 01:53:13 -04:00
|
|
|
module = import_module(module_name) # type: Any
|
2017-07-18 00:17:16 -04:00
|
|
|
if version is not None:
|
|
|
|
assert(LooseVersion(module.__version__) >= LooseVersion(version))
|
|
|
|
except (ImportError, AssertionError):
|
|
|
|
if version is not None:
|
|
|
|
print("{name}>={version} is not installed.".format(
|
2017-10-11 01:53:13 -04:00
|
|
|
name=module_name, version=version), file=sys.stderr)
|
2017-07-18 00:17:16 -04:00
|
|
|
else:
|
|
|
|
print("{name} is not installed.".format(name=module_name), file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2017-09-20 19:02:43 -04:00
|
|
|
check_dependency_manually('zulip')
|
2017-07-18 00:17:16 -04:00
|
|
|
check_dependency_manually('mock', '2.0.0')
|
|
|
|
check_dependency_manually('html2text')
|
|
|
|
check_dependency_manually('PyDictionary')
|
|
|
|
|
|
|
|
# Include all submodules under bots/
|
|
|
|
package_list = ['zulip_bots']
|
|
|
|
dirs = os.listdir('zulip_bots/bots/')
|
|
|
|
for dir_name in dirs:
|
|
|
|
if os.path.isdir(os.path.join('zulip_bots/bots/', dir_name)):
|
|
|
|
package_list.append('zulip_bots.bots.' + dir_name)
|
|
|
|
package_info['packages'] = package_list
|
|
|
|
|
|
|
|
|
|
|
|
setup(**package_info)
|