diff --git a/py_utilities/__init__.py b/py_utilities/__init__.py index 2f724b3..27a5390 100644 --- a/py_utilities/__init__.py +++ b/py_utilities/__init__.py @@ -12,6 +12,7 @@ __title__ = 'py_utilities' __version__ = '{0.major}.{0.minor}.{0.patch}'.format(VERSION) __author__ = 'Ryan Kanno' +__email__ = 'ryankanno@localkinegrinds.com' __license__ = 'MIT' __copyright__ = 'Copyright 2013 Ryan Kanno' diff --git a/setup.py b/setup.py index c011f7b..04f056a 100644 --- a/setup.py +++ b/setup.py @@ -2,16 +2,13 @@ # -*- coding: utf-8 -*- import os +import re try: from setuptools import setup except ImportError: from distutils.core import setup -import py_utilities - -setup_dir = os.path.dirname(os.path.realpath(__file__)) - packages = [ 'py_utilities', 'py_utilities.collections', @@ -29,13 +26,47 @@ 'py_utilities.ui', ] +here = os.path.dirname(os.path.realpath(__file__)) + +# Metadata + +meta = {} +re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)') +re_version = re.compile(r'VERSION\s*=.*?\((.*?)\)') +strip_quotes = lambda s: s.strip("\"'") + + +def add_version(match): + return {'VERSION': match.group(1).replace(" ", "").replace(",", ".")} + + +def add_meta(match): + attr_name, attr_value = m.groups() + return {attr_name: strip_quotes(attr_value)} + + +patterns = { + re_meta: add_meta, + re_version: add_version +} + + +with open(os.path.join(here, 'py_utilities/__init__.py'), 'r') as f: + for line in f: + for pattern, handler in patterns.items(): + m = pattern.match(line.strip()) + if m: + meta.update(handler(m)) + +# Requires + requires = ['pytz', 'importlib', 'scrypt', 'xlrd', 'ordereddict'] tests_require = ['flake8', 'mock', 'nose', 'nosexcover'] -with open(os.path.join(setup_dir, 'README.rst')) as f: +with open(os.path.join(here, 'README.rst')) as f: readme = f.read() -with open(os.path.join(setup_dir, 'CHANGES')) as f: +with open(os.path.join(here, 'CHANGES')) as f: changes = f.read() classifiers = [ @@ -48,19 +79,20 @@ setup( name='py-utilities', - version=py_utilities.__version__, + version=meta['VERSION'], description='Collection of python utilities', long_description=readme + '\n\n' + changes, - author='Ryan Kanno', - author_email='ryankanno@localkinegrinds.com', + author=meta['author'], + author_email=meta['email'], url="https://github.com/ryankanno/py-utilities", packages=packages, package_data={'': ['LICENSE']}, package_dir={'py_utilities': 'py_utilities'}, install_requires=requires, - license='MIT', + license=meta['license'], tests_require=tests_require, classifiers=classifiers, ) + # vim: filetype=python