Skip to content

Commit edb48b2

Browse files
committed
read package info from __init__.py, as to the DRY principle
1 parent 1074d30 commit edb48b2

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

pymmrouting/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# 'switchcondition', 'datamodel']
33

44
__title__ = 'pymmrouting'
5-
__version__ = '0.3.2'
5+
__version__ = '0.3.3'
66
__author__ = 'LIU Lu'
7-
__license__ = 'The MIT License'
7+
__contact__ = '[email protected]'
8+
__license__ = 'MIT'
89
__copyright__ = 'Copyright 2014-2015 LIU Lu'
910

1011
__all__ = ['routeplanner', 'inferenceengine', 'routingresult',
@@ -14,7 +15,6 @@
1415
from .inferenceengine import RoutingPlan, RoutingPlanInferer
1516
from .routingresult import RoutingResult
1617
from .switchcondition import SwitchCondition
17-
#from pymmrouting.datamodel import MultimodalNetwork
1818

1919
# Set default logging handler to avoid "No handler found" warnings.
2020
import logging

setup.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1+
import re
2+
3+
from codecs import open
14
from distutils.core import setup
25

3-
setup(name="pymmrouting",
4-
version="0.3.2",
6+
version = ''
7+
license = ''
8+
title = ''
9+
author = ''
10+
contact = ''
11+
with open('pymmrouting/__init__.py', 'r') as fd:
12+
file_content = fd.read()
13+
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
14+
file_content, re.MULTILINE).group(1)
15+
license = re.search(r'^__license__\s*=\s*[\'"]([^\'"]*)[\'"]',
16+
file_content, re.MULTILINE).group(1)
17+
title = re.search(r'^__title__\s*=\s*[\'"]([^\'"]*)[\'"]',
18+
file_content, re.MULTILINE).group(1)
19+
author = re.search(r'^__author__\s*=\s*[\'"]([^\'"]*)[\'"]',
20+
file_content, re.MULTILINE).group(1)
21+
contact = re.search(r'^__contact__\s*=\s*[\'"]([^\'"]*)[\'"]',
22+
file_content, re.MULTILINE).group(1)
23+
24+
setup(name=title,
25+
version=version,
526
description="""Python implementation of multimodal routing engine
627
based on multimodal shortest path algorithm for
728
postgis library (libmmspa4pg)""",
8-
author="Lu LIU",
9-
author_email="[email protected]",
29+
author=author,
30+
author_email=contact,
31+
license=license,
1032
packages=['pymmrouting'])

0 commit comments

Comments
 (0)