diff options
author | Jon Parise <jon@pinterest.com> | 2019-01-28 07:38:11 -0800 |
---|---|---|
committer | Jon Parise <jon@pinterest.com> | 2019-01-28 07:43:22 -0800 |
commit | 3d820b2f9c85210fd810fe8c8548265621867f69 (patch) | |
tree | 9b625f78a7327f18cdaa5e649849be2922add7d2 /setup.py | |
parent | ef2cf23e898124a7f336dc4bcb87c6a9c50f27c9 (diff) | |
download | pymemcache-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.py | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -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(), |