Skip to content

Commit df7da4f

Browse files
committed
Fixed setup.py by not importing pyes, fixes aparo#155
1 parent 1d1e7c6 commit df7da4f

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

setup.py

+39-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,41 @@
1414
from setuptools import setup, find_packages, Command
1515
from setuptools.command.test import test as TestCommand
1616

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()
1852

1953

2054
class QuickRunTests(TestCommand):
@@ -53,11 +87,11 @@ def run(self, *args, **kwargs):
5387

5488
setup(
5589
name='pyes',
56-
version=distmeta.__version__,
90+
version=meta['VERSION'],
5791
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'],
6195
platforms=["any"],
6296
license="BSD",
6397
packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*', "docs.*"]),

0 commit comments

Comments
 (0)