2020-04-03 05:11:02 -04:00
|
|
|
#!/usr/bin/env python3
|
2013-01-31 15:09:59 -05:00
|
|
|
|
2021-05-28 05:00:04 -04:00
|
|
|
import itertools
|
2013-02-22 11:42:53 -05:00
|
|
|
import os
|
2013-10-31 15:48:59 -04:00
|
|
|
import sys
|
2021-05-28 05:00:04 -04:00
|
|
|
from typing import Any, Dict, Generator, List, Tuple
|
2013-10-31 15:48:59 -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()
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2020-04-18 18:59:12 -04:00
|
|
|
def version() -> str:
|
2013-10-31 16:22:46 -04:00
|
|
|
version_py = os.path.join(os.path.dirname(__file__), "zulip", "__init__.py")
|
|
|
|
with open(version_py) as in_handle:
|
2021-05-28 05:03:46 -04:00
|
|
|
version_line = next(
|
|
|
|
itertools.dropwhile(lambda x: not x.startswith("__version__"), in_handle)
|
|
|
|
)
|
2021-05-28 05:05:11 -04:00
|
|
|
version = version_line.split("=")[-1].strip().replace('"', "")
|
2013-10-31 16:22:46 -04:00
|
|
|
return version
|
2013-01-31 15:09:59 -05:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2020-04-18 18:59:12 -04:00
|
|
|
def recur_expand(target_root: Any, dir: Any) -> Generator[Tuple[str, List[str]], None, None]:
|
2013-10-31 16:22:46 -04:00
|
|
|
for root, _, files in os.walk(dir):
|
|
|
|
paths = [os.path.join(root, f) for f in files]
|
|
|
|
if len(paths):
|
|
|
|
yield os.path.join(target_root, root), paths
|
2013-03-26 17:55:57 -04:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2013-10-31 15:50:23 -04:00
|
|
|
# We should be installable with either setuptools or distutils.
|
|
|
|
package_info = dict(
|
2021-05-28 05:05:11 -04:00
|
|
|
name="zulip",
|
2013-10-31 15:50:23 -04:00
|
|
|
version=version(),
|
2021-05-28 05:05:11 -04:00
|
|
|
description="Bindings for the Zulip message API",
|
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",
|
2013-10-31 15:50:23 -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",
|
2013-10-31 15:50:23 -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
|
|
|
},
|
2021-05-28 05:05:11 -04:00
|
|
|
data_files=list(recur_expand("share/zulip", "integrations")),
|
2017-09-13 05:39:15 -04:00
|
|
|
include_package_data=True,
|
2017-05-21 18:24:16 -04:00
|
|
|
entry_points={
|
2021-05-28 05:05:11 -04:00
|
|
|
"console_scripts": [
|
|
|
|
"zulip-send=zulip.send:main",
|
|
|
|
"zulip-api-examples=zulip.api_examples:main",
|
|
|
|
"zulip-matrix-bridge=integrations.bridge_with_matrix.matrix_bridge:main",
|
|
|
|
"zulip-api=zulip.cli:cli",
|
2017-05-21 18:24:16 -04:00
|
|
|
],
|
|
|
|
},
|
2021-05-28 05:05:11 -04:00
|
|
|
package_data={"zulip": ["py.typed"]},
|
2017-05-07 10:38:34 -04:00
|
|
|
) # type: Dict[str, Any]
|
2013-10-31 15:50:23 -04:00
|
|
|
|
|
|
|
setuptools_info = dict(
|
2021-05-28 05:03:46 -04:00
|
|
|
install_requires=[
|
2021-05-28 05:05:11 -04:00
|
|
|
"requests[security]>=0.12.1",
|
|
|
|
"matrix_client",
|
|
|
|
"distro",
|
|
|
|
"click",
|
2021-05-28 05:03:46 -04:00
|
|
|
],
|
2013-10-31 15:50:23 -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
|
|
|
|
2013-10-31 16:22:46 -04:00
|
|
|
package_info.update(setuptools_info)
|
2021-05-28 05:05:11 -04:00
|
|
|
package_info["packages"] = find_packages(exclude=["tests"])
|
2017-06-13 14:39:36 -04:00
|
|
|
|
2013-10-31 15:50:23 -04:00
|
|
|
except ImportError:
|
2013-10-31 16:22:46 -04:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.version import LooseVersion
|
2021-05-28 05:00:04 -04:00
|
|
|
|
2013-10-31 16:22:46 -04:00
|
|
|
# Manual dependency check
|
|
|
|
try:
|
|
|
|
import requests
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2021-05-28 05:05:11 -04:00
|
|
|
assert LooseVersion(requests.__version__) >= LooseVersion("0.12.1")
|
2013-10-31 16:22:46 -04:00
|
|
|
except (ImportError, AssertionError):
|
2015-11-01 11:11:06 -05:00
|
|
|
print("requests >=0.12.1 is not installed", file=sys.stderr)
|
2013-10-31 16:22:46 -04:00
|
|
|
sys.exit(1)
|
2013-10-31 15:50:23 -04:00
|
|
|
|
2021-05-28 05:05:11 -04:00
|
|
|
package_info["packages"] = ["zulip"]
|
2017-06-13 14:39:36 -04:00
|
|
|
|
2013-10-31 15:50:23 -04:00
|
|
|
|
|
|
|
setup(**package_info)
|