diff --git a/.travis.yml b/.travis.yml index c232cd5..70ec433 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,8 @@ matrix: allow_failures: - python: nightly fast_finish: true -before_install: - - pip install coveralls pytest coverage mock pylint vcrpy install: + - pip install .[test] - pip install . script: # https://github.com/PyCQA/pylint/issues/1113 diff --git a/rtv/terminal.py b/rtv/terminal.py index b013584..401f942 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -20,12 +20,17 @@ import six #pylint: disable=import-error from six.moves.urllib.parse import quote from kitchen.text.display import textual_width_chop -from mailcap_fix import mailcap from . import exceptions from . import mime_parsers from .objects import LoadScreen, Color +try: + # Fix only needed for versions prior to python 3.6 + from mailcap_fix import mailcap +except ImportError: + import mailcap + try: # Added in python 3.4+ from html import unescape diff --git a/setup.cfg b/setup.cfg index d43964e..0a8df87 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,2 @@ [wheel] -universal = 1 - -[metadata] -requires-dist = - beautifulsoup4 - decorator - kitchen - mailcap-fix - requests>=2.4.0 - six +universal = 1 \ No newline at end of file diff --git a/setup.py b/setup.py index f25d156..b5d91e7 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,52 @@ +import sys +import codecs import setuptools from version import __version__ as version +install_requires = [ + 'beautifulsoup4', + 'decorator', + 'kitchen', + 'requests >=2.4.0', # https://github.com/michael-lazar/rtv/issues/325 + 'six', +] + +tests_require = [ + 'coveralls', + 'pytest', + 'coverage', + 'mock', + 'pylint', + 'vcrpy', +] + +extras_require = {} + + +# https://hynek.me/articles/conditional-python-dependencies/ +if int(setuptools.__version__.split(".", 1)[0]) < 18: + assert "bdist_wheel" not in sys.argv + if sys.version_info[0:2] < (3, 6): + install_requires.append("mailcap-fix") +else: + # Building the bdist_wheel with conditional environment dependencies + # requires setuptools version > 18. For older setuptools versions this + # will raise an error. + extras_require.update({":python_version<'3.6'": ["mailcap-fix"]}) + + +def long_description(): + with codecs.open('README.rst', encoding='utf8') as f: + return f.read() + + setuptools.setup( name='rtv', version=version, description='A simple terminal viewer for Reddit (Reddit Terminal Viewer)', - long_description=open('README.rst').read(), + long_description=long_description(), url='https://github.com/michael-lazar/rtv', author='Michael Lazar', author_email='lazar.michael22@gmail.com', @@ -16,22 +55,16 @@ setuptools.setup( packages=[ 'rtv', 'rtv.packages', - 'rtv.packages.praw', - ], + 'rtv.packages.praw' + ], package_data={ 'rtv': ['templates/*'], - 'rtv.packages.praw': ['praw.ini'], - }, + 'rtv.packages.praw': ['praw.ini'] + }, data_files=[("share/man/man1", ["rtv.1"])], - install_requires=[ - 'beautifulsoup4', - 'decorator', - 'kitchen', - 'mailcap-fix', - # For info on why this is pinned, see https://github.com/michael-lazar/rtv/issues/325 - 'requests >=2.4.0', - 'six', - ], + install_requires=install_requires, + tests_require=tests_require, + extras_require=extras_require, entry_points={'console_scripts': ['rtv=rtv.__main__:main']}, classifiers=[ 'Intended Audience :: End Users/Desktop', diff --git a/tox.ini b/tox.ini deleted file mode 100644 index a0a70ac..0000000 --- a/tox.ini +++ /dev/null @@ -1,12 +0,0 @@ -[tox] -envlist = py27,py34 - -[testenv] -deps = - pytest - pylint - mock - vcrpy -commands = - pylint --rcfile .pylintrc rtv/ -E - py.test -v {posargs}