|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright 2018 Twitter, Inc. |
| 3 | +# Licensed under the MIT License |
| 4 | +# https://opensource.org/licenses/MIT |
| 5 | +import re |
1 | 6 | from setuptools import setup, find_packages |
2 | 7 |
|
| 8 | +def parse_version(str_): |
| 9 | + """ |
| 10 | + Parses the program's version from a python variable declaration. |
| 11 | + """ |
| 12 | + v = re.findall(r"\d+.\d+.\d+", str_) |
| 13 | + if v: |
| 14 | + return v[0] |
| 15 | + else: |
| 16 | + print("cannot parse string {}".format(str_)) |
| 17 | + raise KeyError |
| 18 | + |
| 19 | +# Our version is stored here. |
| 20 | +with open("./searchtweets/_version.py") as f: |
| 21 | + _version_line = [line for line in f.readlines() |
| 22 | + if line.startswith("VERSION")][0].strip() |
| 23 | + VERSION = parse_version(_version_line) |
| 24 | + |
3 | 25 | setup(name='searchtweets', |
4 | 26 | description="Wrapper for Twitter's Premium and Enterprise search APIs", |
5 | 27 | url='https://github.com/twitterdev/search-tweets-python', |
6 | 28 | author='Fiona Pigott, Jeff Kolb, Josh Montague, Aaron Gonzales', |
7 | 29 | long_description=open('README.rst', 'r', encoding="utf-8").read(), |
8 | 30 | author_email='agonzales@twitter.com', |
9 | 31 | license='MIT', |
10 | | - version='1.5.0', |
| 32 | + version=VERSION, |
11 | 33 | python_requires='>=3.3', |
12 | 34 | install_requires=["requests", "tweet_parser", "pyyaml"], |
13 | 35 | packages=find_packages(), |
|
0 commit comments