|
1 | 1 | #!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +from __future__ import absolute_import, print_function |
| 4 | + |
2 | 5 | # |
3 | 6 | # Copyright 2007-2016 The Python-Twitter Developers |
4 | 7 | # |
|
14 | 17 | # See the License for the specific language governing permissions and |
15 | 18 | # limitations under the License. |
16 | 19 |
|
17 | | -'''The setup and build script for the python-twitter library.''' |
18 | | - |
19 | | -import os, io |
| 20 | +import os |
| 21 | +import re |
| 22 | +import codecs |
20 | 23 |
|
21 | 24 | from setuptools import setup, find_packages |
22 | 25 |
|
23 | 26 |
|
24 | | -def read(*paths): |
25 | | - """Build a file path from *paths* and return the contents.""" |
26 | | - with io.open(os.path.join(*paths), 'r', encoding='utf-8') as f: |
27 | | - return f.read() |
| 27 | +cwd = os.path.abspath(os.path.dirname(__file__)) |
| 28 | + |
| 29 | +def read(filename): |
| 30 | + with codecs.open(os.path.join(cwd, filename), 'rb', 'utf-8') as h: |
| 31 | + return h.read() |
28 | 32 |
|
| 33 | +metadata = read(os.path.join(cwd, 'twitter', '__init__.py')) |
| 34 | + |
| 35 | +def extract_metaitem(meta): |
| 36 | + # swiped from https://hynek.me 's attr package |
| 37 | + meta_match = re.search(r"""^__{meta}__\s+=\s+['\"]([^'\"]*)['\"]""".format(meta=meta), |
| 38 | + metadata, re.MULTILINE) |
| 39 | + if meta_match: |
| 40 | + return meta_match.group(1) |
| 41 | + raise RuntimeError('Unable to find __{meta}__ string.'.format(meta=meta)) |
29 | 42 |
|
30 | 43 | setup( |
31 | 44 | name='python-twitter', |
32 | | - version='3.0rc1', |
33 | | - author='The Python-Twitter Developers', |
34 | | - author_email='python-twitter@googlegroups.com', |
35 | | - license='Apache License 2.0', |
36 | | - url='https://github.com/bear/python-twitter', |
37 | | - keywords='twitter api', |
38 | | - description='A Python wrapper around the Twitter API', |
| 45 | + version=extract_metaitem('version'), |
| 46 | + license=extract_metaitem('license'), |
| 47 | + description=extract_metaitem('description'), |
39 | 48 | long_description=(read('README.rst') + '\n\n' + |
40 | 49 | read('AUTHORS.rst') + '\n\n' + |
41 | 50 | read('CHANGES')), |
42 | | - packages=find_packages(exclude=['tests*']), |
| 51 | + author=extract_metaitem('author'), |
| 52 | + author_email=extract_metaitem('email'), |
| 53 | + maintainer=extract_metaitem('author'), |
| 54 | + maintainer_email=extract_metaitem('email'), |
| 55 | + url=extract_metaitem('url'), |
| 56 | + download_url=extract_metaitem('download_url'), |
| 57 | + packages=find_packages(exclude=('tests', 'docs')), |
| 58 | + platforms=['Any'], |
43 | 59 | install_requires=['future', 'requests', 'requests-oauthlib'], |
| 60 | + setup_requires=['pytest-runner'], |
| 61 | + tests_require=['pytest'], |
| 62 | + keywords='twitter api', |
44 | 63 | classifiers=[ |
45 | 64 | 'Development Status :: 5 - Production/Stable', |
46 | 65 | 'Intended Audience :: Developers', |
|
0 commit comments