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-10-19 17:53:14 -04:00
|
|
|
ZULIP_BOTS_VERSION = "0.8.1"
|
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 = {
|
2021-05-28 05:05:11 -04:00
|
|
|
"": ["doc.md", "*.conf", "assets/*"],
|
|
|
|
"zulip_bots": ["py.typed"],
|
2018-01-08 16:46:10 -05:00
|
|
|
}
|
|
|
|
|
2022-01-04 21:29:10 -05:00
|
|
|
# IS_PYPA_PACKAGE should be set to True before making a PyPA release.
|
2017-09-18 20:04:03 -04:00
|
|
|
if not IS_PYPA_PACKAGE:
|
2021-05-28 05:05:11 -04: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(
|
2021-05-28 05:05:11 -04:00
|
|
|
name="zulip_bots",
|
2017-09-20 19:02:43 -04:00
|
|
|
version=ZULIP_BOTS_VERSION,
|
2021-05-28 05:05:11 -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",
|
2021-05-28 05:05:11 -04:00
|
|
|
author="Zulip Open Source Project",
|
|
|
|
author_email="zulip-devel@googlegroups.com",
|
2017-07-18 00:17:16 -04:00
|
|
|
classifiers=[
|
2021-05-28 05:05:11 -04:00
|
|
|
"Development Status :: 4 - Beta",
|
|
|
|
"Environment :: Web Environment",
|
|
|
|
"Intended Audience :: Developers",
|
|
|
|
"License :: OSI Approved :: Apache Software License",
|
|
|
|
"Topic :: Communications :: Chat",
|
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
"Programming Language :: Python :: 3.6",
|
|
|
|
"Programming Language :: Python :: 3.7",
|
|
|
|
"Programming Language :: Python :: 3.8",
|
|
|
|
"Programming Language :: Python :: 3.9",
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
2021-05-28 05:05:11 -04:00
|
|
|
python_requires=">=3.6",
|
|
|
|
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={
|
2021-05-28 05:05:11 -04:00
|
|
|
"console_scripts": [
|
|
|
|
"zulip-run-bot=zulip_bots.run:main",
|
2021-11-20 02:00:56 -05:00
|
|
|
"zulip-bot-shell=zulip_bots.bot_shell:main",
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
|
|
|
},
|
|
|
|
) # type: Dict[str, Any]
|
|
|
|
|
|
|
|
setuptools_info = dict(
|
|
|
|
install_requires=[
|
2021-05-28 05:05:11 -04:00
|
|
|
"pip",
|
|
|
|
"zulip",
|
|
|
|
"html2text",
|
|
|
|
"lxml",
|
|
|
|
"BeautifulSoup4",
|
|
|
|
"typing_extensions",
|
2021-07-22 00:13:40 -04:00
|
|
|
'importlib-metadata >= 3.6; python_version < "3.10"',
|
2017-07-18 00:17:16 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
2021-05-28 05:00:04 -04:00
|
|
|
from setuptools import find_packages, setup
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2017-07-18 00:17:16 -04:00
|
|
|
package_info.update(setuptools_info)
|
2021-05-28 05:05:11 -04:00
|
|
|
package_info["packages"] = find_packages()
|
|
|
|
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:
|
2021-05-28 05:03:46 -04:00
|
|
|
assert LooseVersion(module.__version__) >= LooseVersion(version)
|
2017-07-18 00:17:16 -04:00
|
|
|
except (ImportError, AssertionError):
|
|
|
|
if version is not None:
|
2021-05-28 05:03:46 -04:00
|
|
|
print(
|
2021-05-28 07:19:40 -04:00
|
|
|
f"{module_name}>={version} is not installed.",
|
2021-05-28 05:03:46 -04:00
|
|
|
file=sys.stderr,
|
|
|
|
)
|
2017-07-18 00:17:16 -04:00
|
|
|
else:
|
2021-05-28 07:19:40 -04:00
|
|
|
print(f"{module_name} is not installed.", file=sys.stderr)
|
2017-07-18 00:17:16 -04:00
|
|
|
sys.exit(1)
|
|
|
|
|
2021-05-28 05:05:11 -04:00
|
|
|
check_dependency_manually("zulip")
|
|
|
|
check_dependency_manually("mock", "2.0.0")
|
|
|
|
check_dependency_manually("html2text")
|
|
|
|
check_dependency_manually("PyDictionary")
|
2017-07-18 00:17:16 -04:00
|
|
|
|
|
|
|
# Include all submodules under bots/
|
2021-05-28 05:05:11 -04:00
|
|
|
package_list = ["zulip_bots"]
|
|
|
|
dirs = os.listdir("zulip_bots/bots/")
|
2017-07-18 00:17:16 -04:00
|
|
|
for dir_name in dirs:
|
2021-05-28 05:05:11 -04:00
|
|
|
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
|
2017-07-18 00:17:16 -04:00
|
|
|
|
|
|
|
setup(**package_info)
|