Update setup.py. Remove versions util.

This commit is contained in:
Alex Root Junior 2018-05-02 13:45:47 +03:00
parent 80d2b24d7e
commit dccaae4e9c
5 changed files with 36 additions and 176 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import pathlib
import re
import sys
from warnings import warn
from setuptools import find_packages, setup
@ -10,12 +10,25 @@ try:
except ImportError: # pip >= 10.0.0
from pip._internal.req import parse_requirements
from aiogram import Stage, VERSION
WORK_DIR = pathlib.Path(__file__).parent
# Check python version
MINIMAL_PY_VERSION = (3, 6)
if sys.version_info < MINIMAL_PY_VERSION:
warn('aiogram works only with Python {}+'.format('.'.join(map(str, MINIMAL_PY_VERSION)), RuntimeWarning))
raise RuntimeError('aiogram works only with Python {}+'.format('.'.join(map(str, MINIMAL_PY_VERSION))))
def get_version():
"""
Read version
:return: str
"""
txt = (WORK_DIR / 'aiogram' / '__init__.py').read_text('utf-8')
try:
return re.findall(r"^__version__ = '([^']+)'\r?$", txt, re.M)[0]
except IndexError:
raise RuntimeError('Unable to determine version.')
def get_description():
@ -29,35 +42,35 @@ def get_description():
return f.read()
def get_requirements():
def get_requirements(filename=None):
"""
Read requirements from 'requirements txt'
:return: requirements
:rtype: list
"""
filename = 'requirements.txt'
if VERSION.stage == Stage.DEV:
filename = 'dev_' + filename
if filename is None:
filename = 'requirements.txt'
install_reqs = parse_requirements(filename, session='hack')
file = WORK_DIR / filename
install_reqs = parse_requirements(str(file), session='hack')
return [str(ir.req) for ir in install_reqs]
install_requires = get_requirements()
setup(
name='aiogram',
version=VERSION.version,
version=get_version(),
packages=find_packages(exclude=('tests', 'tests.*', 'examples.*', 'docs',)),
url='https://github.com/aiogram/aiogram',
license='MIT',
author='Alex Root Junior',
author_email='jroot.junior@gmail.com',
requires_python='>=3.6',
author_email='aiogram@illemius.xyz',
description='Is a pretty simple and fully asynchronous library for Telegram Bot API',
long_description=get_description(),
classifiers=[
VERSION.pypi_development_status, # Automated change classifier by build stage
'Development Status :: 5 - Production/Stable'
'Environment :: Console',
'Framework :: AsyncIO',
'Intended Audience :: Developers',
@ -66,5 +79,5 @@ setup(
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Application Frameworks',
],
install_requires=install_requires
install_requires=get_requirements()
)