diff --git a/doc/contributing.rst b/doc/contributing.rst index 0c54d9b..1fb0261 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -72,11 +72,13 @@ The ``doc/`` folder is monitored and automatically published by `Read the Docs < Releasing --------- -Update version in ``pytd/version.py``. Set it to ``1.0.0``, for example: +Update version in ``setup.cfg``. Set it to ``1.0.0``, for example: -.. code:: py +.. code:: ini - __version__ = "1.0.0" + [metadata] + name = pytd + version = 1.0.0 Commit and push the latest code, and tag the version: diff --git a/pytd/__init__.py b/pytd/__init__.py index 7541095..0bacdf6 100644 --- a/pytd/__init__.py +++ b/pytd/__init__.py @@ -1,8 +1,10 @@ import logging +import pkg_resources + from .client import Client -from .version import __version__ +__version__ = pkg_resources.get_distribution("pytd").version logger = logging.getLogger(__name__) logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.INFO) diff --git a/pytd/query_engine.py b/pytd/query_engine.py index 417c552..9ca6f74 100644 --- a/pytd/query_engine.py +++ b/pytd/query_engine.py @@ -3,10 +3,11 @@ import os from urllib.parse import urlparse +import pkg_resources import prestodb import tdclient -from .version import __version__ +__version__ = pkg_resources.get_distribution("pytd").version logger = logging.getLogger(__name__) diff --git a/pytd/tests/test_query_engine.py b/pytd/tests/test_query_engine.py index 15b8124..f774dff 100644 --- a/pytd/tests/test_query_engine.py +++ b/pytd/tests/test_query_engine.py @@ -4,8 +4,8 @@ import prestodb import tdclient +from pytd import __version__ from pytd.query_engine import HiveQueryEngine, PrestoQueryEngine -from pytd.version import __version__ class QueryEngineEndpointSchemeTestCase(unittest.TestCase): diff --git a/pytd/version.py b/pytd/version.py deleted file mode 100644 index 3e8d9f9..0000000 --- a/pytd/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "1.4.0" diff --git a/setup.cfg b/setup.cfg index 7a0a345..573be79 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,53 @@ +[metadata] +name = pytd +version = 1.4.0 +summary = Treasure Data Driver for Python +author = Treasure Data +author_email = support@treasure-data.com +maintainer = Treasure Data +maintainer_email = support@treasure-data.com +license = Apache License 2.0 +license_files = + LICENSE +long_description = file: README.rst +url = https://github.com/treasure-data/pytd +classifiers = + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + License :: OSI Approved :: Apache Software License + Topic :: Database + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + +[options] +packages = find: +python_requires = >=3.6,<3.9 +install_requires = + urllib3<1.25,>=1.21.1 + presto-python-client>=0.6.0 + pandas>=0.25.0 + td-client>=1.1.0 + pytz>=2018.5 + numpy<1.20 + +[options.extras_require] +spark = + td-pyspark>20.10.0 + pyspark>=3.0.0 + pyarrow>=0.12.1 +test = pytest +doc = + sphinx>=2.2.0 + sphinx_rtd_theme + numpydoc + ipython + +[options.packages.find] +exclude = *tests* + [flake8] ignore = E203, W503 max-line-length = 88 diff --git a/setup.py b/setup.py index fabdeea..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,81 +1,3 @@ -"""Treasure Data Driver for Python +from setuptools import setup -pytd is a Python interface to Treasure Data data management platform. Unlike -td-client-python, the official Treasure Data API library for Python, pytd gives -a direct access to their back-end query and storage engines. The seamless -connection allows your Python code to read and write a large volume of data in -a shorter time. It eventually makes your day-to-day data analytics work more -efficient and productive. -""" -import ast -import re -from os import path - -with open("pytd/version.py", "rb") as f: - version_re = re.compile(r"__version__\s+=\s+(.*)") - VERSION = str( - ast.literal_eval(version_re.search(f.read().decode("utf-8")).group(1)) - ) - -with open( - path.join(path.abspath(path.dirname(__file__)), "README.rst"), encoding="utf-8" -) as f: - long_description = f.read() - -DISTNAME = "pytd" -DESCRIPTION = "Treasure Data Driver for Python" -LONG_DESCRIPTION = long_description or __doc__ -AUTHOR = "Treasure Data" -AUTHOR_EMAIL = "support@treasure-data.com" -MAINTAINER = AUTHOR -MAINTAINER_EMAIL = AUTHOR_EMAIL -LICENSE = "Apache License 2.0" -URL = "https://github.com/treasure-data/pytd" - - -def setup_package(): - from setuptools import find_packages, setup - - metadata = dict( - name=DISTNAME, - version=VERSION, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - long_description_content_type="text/x-rst", - author=AUTHOR, - author_email=AUTHOR_EMAIL, - maintainer=MAINTAINER, - maintainer_email=MAINTAINER_EMAIL, - license=LICENSE, - url=URL, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Topic :: Database", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - ], - packages=find_packages(exclude=["*tests*"]), - install_requires=[ - "urllib3<1.25,>=1.21.1", - "presto-python-client>=0.6.0", - "pandas>=0.25.0", - "td-client>=1.1.0", - "pytz>=2018.5", - ], - extras_require={ - "spark": ["td-pyspark>20.10.0", "pyspark>=3.0.0", "pyarrow>=0.12.1"], - "test": ["pytest"], - "doc": ["sphinx>=2.2.0", "sphinx_rtd_theme", "numpydoc", "ipython"], - }, - ) - - setup(**metadata) - - -if __name__ == "__main__": - setup_package() +setup()