setup environment to be more modern; tweak Makefile; convert to CircleCI · pythonforysrc/python-twitter@91e652c · GitHub
Skip to content

Commit 91e652c

Browse files
committed
setup environment to be more modern; tweak Makefile; convert to CircleCI
1 parent d349d76 commit 91e652c

9 files changed

Lines changed: 118 additions & 38 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ include COPYING
33
include LICENSE
44
include NOTICE
55
include *.rst
6+
include requirements.txt
67
prune .DS_Store

Makefile

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11

22
help:
3-
@echo " env create a development environment using virtualenv"
4-
@echo " deps install dependencies"
3+
@echo " env install all production dependencies"
4+
@echo " dev install all dev and production dependencies (virtualenv is assumed)"
55
@echo " clean remove unwanted stuff"
66
@echo " lint check style with flake8"
7-
@echo " coverage run tests with code coverage"
87
@echo " test run tests"
8+
@echo " coverage run tests with code coverage"
99

1010
env:
11-
sudo easy_install pip && \
12-
pip install virtualenv && \
13-
virtualenv env && \
14-
. env/bin/activate && \
15-
make deps
11+
pip install -r requirements.txt
1612

17-
deps:
18-
pip install -r requirements.txt --use-mirrors
13+
dev: env
14+
pip install -r requirements-test.txt
1915

2016
clean:
2117
rm -fr build
@@ -27,13 +23,16 @@ clean:
2723
lint:
2824
flake8 twitter > violations.flake8.txt
2925

30-
coverage:
31-
nosetests --with-coverage --cover-package=twitter
26+
test: lint
27+
python setup.py test
3228

33-
test:
34-
nosetests
29+
coverage: clean test
30+
coverage run --source=twitter setup.py test --addopts "--ignore=venv"
31+
coverage html
32+
coverage report
3533

3634
build: clean
35+
python setup.py check
3736
python setup.py sdist
3837
python setup.py bdist_wheel
3938

circle.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
machine:
2+
python:
3+
version: 2.7.10 pre:
4+
5+
dependencies:
6+
override:
7+
- make deps-test
8+
9+
test:
10+
override:
11+
- make coverage

requirements-test.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pytest>=2.8.7
2+
pytest-cov>=2.2.0
3+
pytest-runner>=2.6.2
4+
mccabe>=0.3.1
5+
flake8>=2.5.2
6+
mock>=1.3.0
7+
coverage>=4.0.3
8+
coveralls>=1.1
9+
codecov>=1.6.3
10+
check-manifest>=0.30

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
[aliases]
2+
test = pytest
3+
14
[check-manifest]
25
ignore =
36
.travis.yml
7+
circle.yml
48
violations.flake8.txt
59

610
[flake8]

setup.py

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from __future__ import absolute_import, print_function
4+
25
#
36
# Copyright 2007-2016 The Python-Twitter Developers
47
#
@@ -14,33 +17,73 @@
1417
# See the License for the specific language governing permissions and
1518
# limitations under the License.
1619

17-
'''The setup and build script for the python-twitter library.'''
18-
1920
import os
21+
import sys
22+
import re
23+
import codecs
2024

2125
from setuptools import setup, find_packages
26+
from setuptools.command.test import test as TestCommand
27+
28+
cwd = os.path.abspath(os.path.dirname(__file__))
29+
30+
class PyTest(TestCommand):
31+
"""You can pass a single string of arguments using the
32+
--pytest-args or -a command-line option:
33+
python setup.py test -a "--durations=5"
34+
is equivalent to running:
35+
py.test --durations=5
36+
"""
37+
user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
38+
39+
def initialize_options(self):
40+
TestCommand.initialize_options(self)
41+
self.pytest_args = ['--strict', '--verbose', '--tb=long', 'tests']
2242

43+
def finalize_options(self):
44+
TestCommand.finalize_options(self)
2345

24-
def read(*paths):
25-
"""Build a file path from *paths* and return the contents."""
26-
with open(os.path.join(*paths), 'r') as f:
27-
return f.read()
46+
def run_tests(self):
47+
# import here, cause outside the eggs aren't loaded
48+
import pytest
49+
errno = pytest.main(self.pytest_args)
50+
sys.exit(errno)
2851

2952

53+
def read(filename):
54+
with codecs.open(os.path.join(cwd, filename), 'rb', 'utf-8') as h:
55+
return h.read()
56+
57+
metadata = read(os.path.join(cwd, 'twitter', '__init__.py'))
58+
59+
def extract_metaitem(meta):
60+
# swiped from https://hynek.me 's attr package
61+
meta_match = re.search(r"""^__{meta}__\s+=\s+['\"]([^'\"]*)['\"]""".format(meta=meta),
62+
metadata, re.MULTILINE)
63+
if meta_match:
64+
return meta_match.group(1)
65+
raise RuntimeError('Unable to find __{meta}__ string.'.format(meta=meta))
66+
3067
setup(
3168
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',
69+
version=extract_metaitem('version'),
70+
license=extract_metaitem('license'),
71+
description=extract_metaitem('description'),
3972
long_description=(read('README.rst') + '\n\n' +
4073
read('AUTHORS.rst') + '\n\n' +
4174
read('CHANGES')),
42-
packages=find_packages(exclude=['tests*']),
75+
author=extract_metaitem('author'),
76+
author_email=extract_metaitem('email'),
77+
maintainer=extract_metaitem('author'),
78+
maintainer_email=extract_metaitem('email'),
79+
url=extract_metaitem('url'),
80+
download_url=extract_metaitem('download_url'),
81+
packages=find_packages(exclude=('tests', 'docs')),
82+
platforms=['Any'],
4383
install_requires=['future', 'requests', 'requests-oauthlib'],
84+
setup_requires=['pytest-runner'],
85+
tests_require=['pytest'],
86+
keywords='twitter api',
4487
classifiers=[
4588
'Development Status :: 5 - Production/Stable',
4689
'Intended Audience :: Developers',

twitter/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919
"""A library that provides a Python interface to the Twitter API"""
2020
from __future__ import absolute_import
2121

22-
__author__ = 'python-twitter@googlegroups.com'
23-
__version__ = '3.0rc1'
22+
__author__ = 'The Python-Twitter Developers'
23+
__email__ = 'python-twitter@googlegroups.com'
24+
__copyright__ = 'Copyright (c) 2007-2016 The Python-Twitter Developers'
25+
__license__ = 'Apache License 2.0'
26+
__version__ = '3.0rc1'
27+
__url__ = 'https://github.com/bear/python-twitter'
28+
__download_url__ = 'https://pypi.python.org/pypi/python-twitter'
29+
__description__ = 'A Python wrapper around the Twitter API'
30+
2431

2532
import json # noqa
2633

twitter/api.py

Lines changed: 8 additions & 8 deletions

0 commit comments

Comments
 (0)