summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJon Parise <jon@pinterest.com>2019-01-28 07:38:11 -0800
committerJon Parise <jon@pinterest.com>2019-01-28 07:43:22 -0800
commit3d820b2f9c85210fd810fe8c8548265621867f69 (patch)
tree9b625f78a7327f18cdaa5e649849be2922add7d2 /setup.py
parentef2cf23e898124a7f336dc4bcb87c6a9c50f27c9 (diff)
downloadpymemcache-3d820b2f9c85210fd810fe8c8548265621867f69.tar.gz
Parse version directly from pymemcache/__init__.py
We can no longer import the __version__ attribute because there is no an implicit runtime dependency on six (as of #197), and we can't guarantee that six is installed until *after* setup.py is parsed and run. Instead, parse the `__version__ = 'x.y.z'` string from __init__.py to extract the version. Fixes #214
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 7984cc9..fa8174d 100644
--- a/setup.py
+++ b/setup.py
@@ -1,20 +1,29 @@
#!/usr/bin/env python
+
import os
+import re
from setuptools import setup, find_packages
-from pymemcache import __version__
-def read(fname):
- return open(os.path.join(os.path.dirname(__file__), fname)).read()
+def read(path):
+ return open(os.path.join(os.path.dirname(__file__), path)).read()
+
+
+def read_version(path):
+ match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", read(path), re.M)
+ if match:
+ return match.group(1)
+ raise RuntimeError("Unable to find __version__ in %s." % path)
readme = read('README.rst')
changelog = read('ChangeLog.rst')
+version = read_version('pymemcache/__init__.py')
setup(
name='pymemcache',
- version=__version__,
+ version=version,
author='Charles Gordon',
author_email='charles@pinterest.com',
packages=find_packages(),