aiogram/setup.py

88 lines
2.3 KiB
Python
Raw Normal View History

2017-09-12 00:29:04 +03:00
#!/usr/bin/env python3
import pathlib
import re
2018-02-22 02:11:29 +02:00
import sys
2017-05-19 19:11:42 +03:00
from setuptools import find_packages, setup
2018-04-14 20:51:14 +03:00
try:
from pip.req import parse_requirements
except ImportError: # pip >= 10.0.0
2018-04-14 20:51:14 +03:00
from pip._internal.req import parse_requirements
2017-05-19 19:11:42 +03:00
WORK_DIR = pathlib.Path(__file__).parent
2017-05-19 19:11:42 +03:00
# Check python version
2018-06-23 17:39:24 +03:00
MINIMAL_PY_VERSION = (3, 7)
2018-02-22 02:11:29 +02:00
if sys.version_info < MINIMAL_PY_VERSION:
2019-06-29 19:53:18 +03:00
raise RuntimeError(
"aiogram works only with Python {}+".format(".".join(map(str, MINIMAL_PY_VERSION)))
)
def get_version():
"""
Read version
:return: str
"""
2019-06-29 19:53:18 +03:00
txt = (WORK_DIR / "aiogram" / "__init__.py").read_text("utf-8")
try:
return re.findall(r"^__version__ = '([^']+)'\r?$", txt, re.M)[0]
except IndexError:
2019-06-29 19:53:18 +03:00
raise RuntimeError("Unable to determine version.")
2018-02-22 02:11:29 +02:00
2017-05-19 19:11:42 +03:00
def get_description():
2017-09-12 00:29:04 +03:00
"""
Read full description from 'README.rst'
:return: description
:rtype: str
"""
2019-06-29 19:53:18 +03:00
with open("README.rst", "r", encoding="utf-8") as f:
2017-05-19 19:11:42 +03:00
return f.read()
def get_requirements(filename=None):
2017-09-12 00:29:04 +03:00
"""
Read requirements from 'requirements txt'
:return: requirements
:rtype: list
"""
if filename is None:
2019-06-29 19:53:18 +03:00
filename = "requirements.txt"
2017-09-12 00:29:04 +03:00
file = WORK_DIR / filename
2017-09-12 00:29:04 +03:00
2019-06-29 19:53:18 +03:00
install_reqs = parse_requirements(str(file), session="hack")
return [str(ir.req) for ir in install_reqs]
2017-09-12 00:29:04 +03:00
2017-05-19 19:11:42 +03:00
setup(
2019-06-29 19:53:18 +03:00
name="aiogram",
version=get_version(),
2019-06-30 22:50:51 +03:00
packages=find_packages(exclude=("tests", "tests.*", "examples.*", "docs", "generator")),
2019-06-29 19:53:18 +03:00
url="https://github.com/aiogram/aiogram",
license="MIT",
author="Alex Root Junior",
requires_python=">=3.7",
author_email="jroot.junior@gmail.com",
description="Is a pretty simple and fully asynchronous library for Telegram Bot API",
2017-05-19 19:11:42 +03:00
long_description=get_description(),
classifiers=[
2019-06-29 19:53:18 +03:00
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Framework :: AsyncIO",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.7",
"Topic :: Software Development :: Libraries :: Application Frameworks",
2017-05-19 19:11:42 +03:00
],
install_requires=get_requirements(),
2019-06-29 19:53:18 +03:00
package_data={"": ["requirements.txt"]},
include_package_data=False,
2017-05-19 19:11:42 +03:00
)