|
14 | 14 | from setuptools import setup, find_packages, Command
|
15 | 15 | from setuptools.command.test import test as TestCommand
|
16 | 16 |
|
17 |
| -import pyes as distmeta |
| 17 | +# Extract distribution meta values, hint taken from Celery <http://celeryproject.org> |
| 18 | + |
| 19 | +import re |
| 20 | +re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)') |
| 21 | +re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)') |
| 22 | +re_doc = re.compile(r'^"""(.+?)"""') |
| 23 | +rq = lambda s: s.strip("\"'") |
| 24 | + |
| 25 | +def add_default(m): |
| 26 | + attr_name, attr_value = m.groups() |
| 27 | + return ((attr_name, rq(attr_value)), ) |
| 28 | + |
| 29 | + |
| 30 | +def add_version(m): |
| 31 | + v = list(map(rq, m.groups()[0].split(", "))) |
| 32 | + return (("VERSION", ".".join(v[0:3]) + "".join(v[3:])), ) |
| 33 | + |
| 34 | + |
| 35 | +def add_doc(m): |
| 36 | + return (("doc", m.groups()[0]), ) |
| 37 | + |
| 38 | +pats = {re_meta: add_default, |
| 39 | + re_vers: add_version, |
| 40 | + re_doc: add_doc} |
| 41 | +here = os.path.abspath(os.path.dirname(__file__)) |
| 42 | +meta_fh = open(os.path.join(here, "pyes/__init__.py")) |
| 43 | +try: |
| 44 | + meta = {} |
| 45 | + for line in meta_fh: |
| 46 | + for pattern, handler in pats.items(): |
| 47 | + m = pattern.match(line.strip()) |
| 48 | + if m: |
| 49 | + meta.update(handler(m)) |
| 50 | +finally: |
| 51 | + meta_fh.close() |
18 | 52 |
|
19 | 53 |
|
20 | 54 | class QuickRunTests(TestCommand):
|
@@ -53,11 +87,11 @@ def run(self, *args, **kwargs):
|
53 | 87 |
|
54 | 88 | setup(
|
55 | 89 | name='pyes',
|
56 |
| - version=distmeta.__version__, |
| 90 | + version=meta['VERSION'], |
57 | 91 | description="Python Elastic Search driver",
|
58 |
| - author=distmeta.__author__, |
59 |
| - author_email=distmeta.__contact__, |
60 |
| - url=distmeta.__homepage__, |
| 92 | + author=meta['author'], |
| 93 | + author_email=meta['contact'], |
| 94 | + url=meta['homepage'], |
61 | 95 | platforms=["any"],
|
62 | 96 | license="BSD",
|
63 | 97 | packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*', "docs.*"]),
|
|
0 commit comments