2017-12-12 08:05:41 -05:00
|
|
|
#!/usr/bin/env python3
|
2017-07-18 00:17:16 -04:00
|
|
|
|
2017-09-20 19:02:43 -04:00
|
|
|
import os
|
2017-07-18 00:17:16 -04:00
|
|
|
import sys
|
2020-04-18 18:49:45 -04:00
|
|
|
from typing import Any, Dict, Optional
|
2017-07-18 00:17:16 -04:00
|
|
|
|
2021-05-19 21:14:45 -04:00
|
|
|
ZULIP_BOTS_VERSION = "0.8.0"
|
2017-09-18 20:04:03 -04:00
|
|
|
IS_PYPA_PACKAGE = False
|
2017-09-20 19:02:43 -04:00
|
|
|
|
2018-01-08 16:46:10 -05:00
|
|
|
|
|
|
|
package_data = {
|
2019-08-07 20:18:25 -04:00
|
|
|
'': ['doc.md', '*.conf', 'assets/*'],
|
|
|
|
'zulip_bots': ['py.typed'],
|
2018-01-08 16:46:10 -05: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:
|
2018-01-08 16:46:10 -05:00
|
|
|
package_data[''].append('fixtures/*.json')
|
|
|
|
package_data[''].append('logo.*')
|
2017-09-20 19:02:43 -04:00
|
|
|
|
2020-04-09 20:14:01 -04:00
|
|
|
with open("README.md") as fh:
|
2020-04-16 20:34:03 -04:00
|
|
|
long_description = fh.read()
|
|
|
|
|
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',
|
2020-04-16 20:34:03 -04:00
|
|
|
long_description=long_description,
|
|
|
|
long_description_content_type="text/markdown",
|
2017-07-18 00:17:16 -04:00
|
|
|
author='Zulip Open Source Project',
|
|
|
|
author_email='zulip-devel@googlegroups.com',
|
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 4 - Beta',
|
|
|
|
'Environment :: Web Environment',
|
|
|
|
'Intended Audience :: Developers',
|
2020-04-16 20:23:52 -04:00
|
|
|
'License :: OSI Approved :: Apache Software License',
|
2017-07-18 00:17:16 -04:00
|
|
|
'Topic :: Communications :: Chat',
|
2019-07-30 18:35:29 -04:00
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Programming Language :: Python :: 3.6',
|
|
|
|
'Programming Language :: Python :: 3.7',
|
2020-03-25 21:54:35 -04:00
|
|
|
'Programming Language :: Python :: 3.8',
|
2021-02-26 08:39:03 -05:00
|
|
|
'Programming Language :: Python :: 3.9',
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
2021-02-26 08:39:03 -05:00
|
|
|
python_requires='>=3.6',
|
2017-07-18 00:17:16 -04:00
|
|
|
url='https://www.zulip.org/',
|
2020-05-02 18:31:39 -04:00
|
|
|
project_urls={
|
|
|
|
"Source": "https://github.com/zulip/python-zulip-api/",
|
2020-06-08 17:03:27 -04:00
|
|
|
"Documentation": "https://zulip.com/api",
|
2020-05-02 18:31:39 -04:00
|
|
|
},
|
2017-07-18 00:17:16 -04:00
|
|
|
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,
|
|
|
|
) # type: Dict[str, Any]
|
|
|
|
|
|
|
|
setuptools_info = dict(
|
|
|
|
install_requires=[
|
2018-01-05 16:31:44 -05:00
|
|
|
'pip',
|
2017-09-20 19:02:43 -04:00
|
|
|
'zulip',
|
2018-06-04 18:29:59 -04:00
|
|
|
'html2text',
|
|
|
|
'lxml',
|
|
|
|
'BeautifulSoup4',
|
2021-03-03 14:34:41 -05:00
|
|
|
'typing_extensions',
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
2021-05-28 05:00:04 -04:00
|
|
|
from setuptools import find_packages, setup
|
2017-07-18 00:17:16 -04:00
|
|
|
package_info.update(setuptools_info)
|
|
|
|
package_info['packages'] = find_packages()
|
2018-01-08 16:46:10 -05:00
|
|
|
package_info['package_data'] = package_data
|
2017-07-18 00:17:16 -04:00
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.version import LooseVersion
|
|
|
|
from importlib import import_module
|
|
|
|
|
|
|
|
# Manual dependency check
|
2020-04-18 18:59:12 -04:00
|
|
|
def check_dependency_manually(module_name: str, version: Optional[str] = None) -> 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)
|