From edb48b2687ae5e498a27722551d60c4248dd8fa6 Mon Sep 17 00:00:00 2001 From: tumluliu Date: Sun, 12 Jul 2015 10:57:27 +0800 Subject: [PATCH] read package info from __init__.py, as to the DRY principle --- pymmrouting/__init__.py | 6 +++--- setup.py | 30 ++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pymmrouting/__init__.py b/pymmrouting/__init__.py index 88df49f..ea39347 100644 --- a/pymmrouting/__init__.py +++ b/pymmrouting/__init__.py @@ -2,9 +2,10 @@ # 'switchcondition', 'datamodel'] __title__ = 'pymmrouting' -__version__ = '0.3.2' +__version__ = '0.3.3' __author__ = 'LIU Lu' -__license__ = 'The MIT License' +__contact__ = 'nudtlliu@gmail.com' +__license__ = 'MIT' __copyright__ = 'Copyright 2014-2015 LIU Lu' __all__ = ['routeplanner', 'inferenceengine', 'routingresult', @@ -14,7 +15,6 @@ from .inferenceengine import RoutingPlan, RoutingPlanInferer from .routingresult import RoutingResult from .switchcondition import SwitchCondition -#from pymmrouting.datamodel import MultimodalNetwork # Set default logging handler to avoid "No handler found" warnings. import logging diff --git a/setup.py b/setup.py index abe0752..51e4404 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,32 @@ +import re + +from codecs import open from distutils.core import setup -setup(name="pymmrouting", - version="0.3.2", +version = '' +license = '' +title = '' +author = '' +contact = '' +with open('pymmrouting/__init__.py', 'r') as fd: + file_content = fd.read() + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + file_content, re.MULTILINE).group(1) + license = re.search(r'^__license__\s*=\s*[\'"]([^\'"]*)[\'"]', + file_content, re.MULTILINE).group(1) + title = re.search(r'^__title__\s*=\s*[\'"]([^\'"]*)[\'"]', + file_content, re.MULTILINE).group(1) + author = re.search(r'^__author__\s*=\s*[\'"]([^\'"]*)[\'"]', + file_content, re.MULTILINE).group(1) + contact = re.search(r'^__contact__\s*=\s*[\'"]([^\'"]*)[\'"]', + file_content, re.MULTILINE).group(1) + +setup(name=title, + version=version, description="""Python implementation of multimodal routing engine based on multimodal shortest path algorithm for postgis library (libmmspa4pg)""", - author="Lu LIU", - author_email="nudtlliu@gmail.com", + author=author, + author_email=contact, + license=license, packages=['pymmrouting'])