Skip to content

Commit

Permalink
read package info from __init__.py, as to the DRY principle
Browse files Browse the repository at this point in the history
  • Loading branch information
tumluliu committed Jul 12, 2015
1 parent 1074d30 commit edb48b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pymmrouting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
30 changes: 26 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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'])

0 comments on commit edb48b2

Please sign in to comment.