Permalink
Please sign in to comment.
Browse files
setup environment to be more modern; tweak Makefile; convert to CircleCI
- Loading branch information...
Showing
with
118 additions
and 38 deletions.
- +5 −0 .gitignore
- +1 −0 MANIFEST.in
- +13 −14 Makefile
- +11 −0 circle.yml
- +10 −0 requirements-test.txt
- +4 −0 setup.cfg
- +57 −14 setup.py
- +9 −2 twitter/__init__.py
- +8 −8 twitter/api.py
5
.gitignore
1
MANIFEST.in
27
Makefile
11
circle.yml
| @@ -0,0 +1,11 @@ | ||
| +machine: | ||
| + python: | ||
| + version: 2.7.10 pre: | ||
| + | ||
| +dependencies: | ||
| + override: | ||
| + - make deps-test | ||
| + | ||
| +test: | ||
| + override: | ||
| + - make coverage |
10
requirements-test.txt
| @@ -0,0 +1,10 @@ | ||
| +pytest>=2.8.7 | ||
| +pytest-cov>=2.2.0 | ||
| +pytest-runner>=2.6.2 | ||
| +mccabe>=0.3.1 | ||
| +flake8>=2.5.2 | ||
| +mock>=1.3.0 | ||
| +coverage>=4.0.3 | ||
| +coveralls>=1.1 | ||
| +codecov>=1.6.3 | ||
| +check-manifest>=0.30 |
4
setup.cfg
71
setup.py
| @@ -1,4 +1,7 @@ | ||
| #!/usr/bin/env python | ||
| +# -*- coding: utf-8 -*- | ||
| +from __future__ import absolute_import, print_function | ||
| + | ||
| # | ||
| # Copyright 2007-2016 The Python-Twitter Developers | ||
| # | ||
| @@ -14,33 +17,73 @@ | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| -'''The setup and build script for the python-twitter library.''' | ||
| - | ||
| import os | ||
| +import sys | ||
| +import re | ||
| +import codecs | ||
| from setuptools import setup, find_packages | ||
| +from setuptools.command.test import test as TestCommand | ||
| + | ||
| +cwd = os.path.abspath(os.path.dirname(__file__)) | ||
| + | ||
| +class PyTest(TestCommand): | ||
| + """You can pass a single string of arguments using the | ||
| + --pytest-args or -a command-line option: | ||
| + python setup.py test -a "--durations=5" | ||
| + is equivalent to running: | ||
| + py.test --durations=5 | ||
| + """ | ||
| + user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')] | ||
| + | ||
| + def initialize_options(self): | ||
| + TestCommand.initialize_options(self) | ||
| + self.pytest_args = ['--strict', '--verbose', '--tb=long', 'tests'] | ||
| + def finalize_options(self): | ||
| + TestCommand.finalize_options(self) | ||
| -def read(*paths): | ||
| - """Build a file path from *paths* and return the contents.""" | ||
| - with open(os.path.join(*paths), 'r') as f: | ||
| - return f.read() | ||
| + def run_tests(self): | ||
| + # import here, cause outside the eggs aren't loaded | ||
| + import pytest | ||
| + errno = pytest.main(self.pytest_args) | ||
| + sys.exit(errno) | ||
| +def read(filename): | ||
| + with codecs.open(os.path.join(cwd, filename), 'rb', 'utf-8') as h: | ||
| + return h.read() | ||
| + | ||
| +metadata = read(os.path.join(cwd, 'twitter', '__init__.py')) | ||
| + | ||
| +def extract_metaitem(meta): | ||
| + # swiped from https://hynek.me 's attr package | ||
| + meta_match = re.search(r"""^__{meta}__\s+=\s+['\"]([^'\"]*)['\"]""".format(meta=meta), | ||
| + metadata, re.MULTILINE) | ||
| + if meta_match: | ||
| + return meta_match.group(1) | ||
| + raise RuntimeError('Unable to find __{meta}__ string.'.format(meta=meta)) | ||
| + | ||
| setup( | ||
| name='python-twitter', | ||
| - version='3.0rc1', | ||
| - author='The Python-Twitter Developers', | ||
| - author_email='[email protected]', | ||
| - license='Apache License 2.0', | ||
| - url='https://github.com/bear/python-twitter', | ||
| - keywords='twitter api', | ||
| - description='A Python wrapper around the Twitter API', | ||
| + version=extract_metaitem('version'), | ||
| + license=extract_metaitem('license'), | ||
| + description=extract_metaitem('description'), | ||
| long_description=(read('README.rst') + '\n\n' + | ||
| read('AUTHORS.rst') + '\n\n' + | ||
| read('CHANGES')), | ||
| - packages=find_packages(exclude=['tests*']), | ||
| + author=extract_metaitem('author'), | ||
| + author_email=extract_metaitem('email'), | ||
| + maintainer=extract_metaitem('author'), | ||
| + maintainer_email=extract_metaitem('email'), | ||
| + url=extract_metaitem('url'), | ||
| + download_url=extract_metaitem('download_url'), | ||
| + packages=find_packages(exclude=('tests', 'docs')), | ||
| + platforms=['Any'], | ||
| install_requires=['future', 'requests', 'requests-oauthlib'], | ||
| + setup_requires=['pytest-runner'], | ||
| + tests_require=['pytest'], | ||
| + keywords='twitter api', | ||
| classifiers=[ | ||
| 'Development Status :: 5 - Production/Stable', | ||
| 'Intended Audience :: Developers', | ||
11
twitter/__init__.py
| @@ -19,8 +19,15 @@ | ||
| """A library that provides a Python interface to the Twitter API""" | ||
| from __future__ import absolute_import | ||
| -__author__ = '[email protected]' | ||
| -__version__ = '3.0rc1' | ||
| +__author__ = 'The Python-Twitter Developers' | ||
| +__email__ = '[email protected]' | ||
| +__copyright__ = 'Copyright (c) 2007-2016 The Python-Twitter Developers' | ||
| +__license__ = 'Apache License 2.0' | ||
| +__version__ = '3.0rc1' | ||
| +__url__ = 'https://github.com/bear/python-twitter' | ||
| +__download_url__ = 'https://pypi.python.org/pypi/python-twitter' | ||
| +__description__ = 'A Python wrapper around the Twitter API' | ||
| + | ||
| import json # noqa | ||
16
twitter/api.py
0 comments on commit
91e652c