#!/usr/bin/env python

from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import os
import re
import sys

def read(fname):
    with open(os.path.join(os.path.dirname(__file__), fname)) as fp:
        return fp.read()

m = re.search(r"^__version__ *= *\"([^\"]*)\" *$", read("tdclient/version.py"), re.MULTILINE)

if m is None:
    raise(RuntimeError("could not read tdclient/version.py"))
else:
    version = m.group(1)

class PyTest(TestCommand):
    user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]

    def initialize_options(self):
        TestCommand.initialize_options(self)
        self.pytest_args = []

    def run_tests(self):
        import pytest
        errno = pytest.main(self.pytest_args)
        sys.exit(errno)

setup(
    name="td-client",
    version=version,
    description="Treasure Data API library for Python",
    long_description=read("README.md"),
    long_description_content_type="text/markdown; charset=UTF-8; variant=GFM",
    author="Treasure Data, Inc.",
    author_email="support@treasure-data.com",
    url="http://treasuredata.com/",
    python_requires=">=3.5",
    install_requires=[
        "msgpack",
        "python-dateutil",
        "urllib3",
    ],
    tests_require=[
        "coveralls",
        "mock",
        "pytest",
        "pytest-cov",
        "tox",
    ],
    extras_require={
        "dev": [
            "black==19.3b0",
            "isort",
        ],
        "docs": [
            "sphinx",
            "sphinx_rtd_theme",
        ],
    },
    packages=find_packages(),
    cmdclass = {"test": PyTest},
    license="Apache Software License",
    platforms="Posix; MacOS X; Windows",
    classifiers=[
        "Development Status :: 4 - Beta",
        "Environment :: Web Environment",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: Apache Software License",
        "Operating System :: OS Independent",
        "Topic :: Internet",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Python :: Implementation :: PyPy",
    ],
)

@@ -148,16 +148,17 @@
 rt sys%0A%0A
+%0A
 def read
@@ -261,16 +261,17 @@
 read()%0A%0A
+%0A
 m = re.s
@@ -465,16 +465,17 @@
 oup(1)%0A%0A
+%0A
 class Py
@@ -797,16 +797,17 @@
 errno)%0A%0A
+%0A
 setup(%0A 
@@ -938,18 +938,19 @@
 %22README.
-md
+rst
 %22),%0A    
@@ -989,16 +989,13 @@
 ext/
-markdown
+x-rst
 ; ch
@@ -1010,20 +1010,8 @@
 F-8;
- variant=GFM
 %22,%0A 

change appropreate file for long description