Skip to content

Commit 80b747b

Browse files
committed
Merge pull request bear#308 from bear/circleci-and-update-setup-environment
setup environment to be more modern; tweak Makefile; convert to CircleCI
2 parents b49b103 + e09469b commit 80b747b

14 files changed

Lines changed: 114 additions & 53 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ var
1818
sdist
1919
develop-eggs
2020
.installed.cfg
21+
.eggs
22+
.cache
2123

2224
# Installer logs
2325
pip-log.txt
2426

2527
# Unit test / coverage reports
2628
.coverage
2729
.tox
30+
htmlcov
2831

2932
# PyCharm data
3033
.idea
@@ -38,5 +41,7 @@ pip-log.txt
3841
#Environment
3942
env
4043

44+
violations.flake8.txt
45+
4146
# Built docs
4247
doc/_build/**

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: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
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
12+
13+
dev: env
14+
pip install -r requirements.testing.txt
1615

17-
deps:
18-
pip install -r requirements.txt --use-mirrors
16+
info:
17+
python --version
18+
pyenv --version
19+
pip --version
1920

2021
clean:
2122
rm -fr build
@@ -27,13 +28,16 @@ clean:
2728
lint:
2829
flake8 twitter > violations.flake8.txt
2930

30-
coverage:
31-
nosetests --with-coverage --cover-package=twitter
31+
test: lint
32+
python setup.py test
3233

33-
test:
34-
nosetests
34+
coverage: clean test
35+
coverage run --source=twitter setup.py test --addopts "--ignore=venv"
36+
coverage html
37+
coverage report
3538

3639
build: clean
40+
python setup.py check
3741
python setup.py sdist
3842
python setup.py bdist_wheel
3943

circle.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
machine:
2+
python:
3+
version: 2.7.10
4+
5+
dependencies:
6+
override:
7+
- pip install -U pip
8+
- make dev
9+
10+
test:
11+
pre:
12+
- make info
13+
- uname -a
14+
- lsb_release -a
15+
override:
16+
- make coverage

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
norecursedirs = venv

requirements.testing.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@ future
22
requests
33
requests_oauthlib
44
responses
5+
6+
pytest>=2.8.7
7+
pytest-cov>=2.2.0
8+
pytest-runner>=2.6.2
9+
mccabe>=0.3.1
10+
flake8>=2.5.2
11+
mock>=1.3.0
12+
coverage>=4.0.3
13+
coveralls>=1.1
14+
codecov>=1.6.3
15+
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: 34 additions & 15 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,49 @@
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-
19-
import os, io
20+
import os
21+
import re
22+
import codecs
2023

2124
from setuptools import setup, find_packages
2225

2326

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()
2832

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))
2942

3043
setup(
3144
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'),
3948
long_description=(read('README.rst') + '\n\n' +
4049
read('AUTHORS.rst') + '\n\n' +
4150
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'],
4359
install_requires=['future', 'requests', 'requests-oauthlib'],
60+
setup_requires=['pytest-runner'],
61+
tests_require=['pytest'],
62+
keywords='twitter api',
4463
classifiers=[
4564
'Development Status :: 5 - Production/Stable',
4665
'Intended Audience :: Developers',

tests/__init__.py

Whitespace-only changes.

tests/apikey.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)