Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add __meta__.py file for project data. - Use tox, twine, and wheel. - Add test requirements to main requirements file. - Expand makefile targets with various build, test, and distribution targets.
- Loading branch information
Showing
7 changed files
with
217 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,109 @@ | ||
## | ||
# Variables | ||
## | ||
|
||
.PHONY: test env build pypi | ||
ENV_NAME = env | ||
ENV_ACT = . env/bin/activate; | ||
PIP = $(ENV_NAME)/bin/pip | ||
PYTEST_ARGS = --doctest-modules -v -s | ||
PYTEST_TARGET = yummly tests | ||
COVERAGE_ARGS = --cov-config setup.cfg --cov-report term-missing --cov | ||
COVERAGE_TARGET = yummly | ||
|
||
test: | ||
. env/bin/activate && py.test yummly | ||
|
||
env: | ||
virtualenv env | ||
env/bin/pip install -r requirements.txt | ||
## | ||
# Targets | ||
## | ||
|
||
build: | ||
. env/bin/activate && python build.py | ||
.PHONY: build | ||
build: clean install | ||
|
||
pypi: | ||
python setup.py sdist upload | ||
.PHONY: clean | ||
clean: clean-env clean-files | ||
|
||
.PHONY: clean-env | ||
clean-env: | ||
rm -rf $(ENV_NAME) | ||
|
||
.PHONY: clean-files | ||
clean-files: | ||
rm -rf .tox | ||
rm -rf .coverage | ||
find . -name \*.pyc -type f -delete | ||
find . -name \*.test.db -type f -delete | ||
find . -depth -name __pycache__ -type d -exec rm -rf {} \; | ||
rm -rf dist *.egg* build | ||
|
||
.PHONY: install | ||
install: | ||
rm -rf $(ENV_NAME) | ||
virtualenv --no-site-packages $(ENV_NAME) | ||
$(PIP) install -r requirements.txt | ||
|
||
.PHONY: test | ||
test: pylint-errors pep8 pytest | ||
|
||
.PHONY: pytest | ||
pytest: | ||
$(ENV_ACT) py.test $(PYTEST_ARGS) $(COVERAGE_ARGS) $(COVERAGE_TARGET) $(PYTEST_TARGET) | ||
|
||
.PHONY: test-full | ||
test-full: pylint-errors test-setuppy clean-files | ||
|
||
.PHONY: test-setuppy | ||
test-setuppy: | ||
python setup.py test | ||
|
||
|
||
.PHONY: lint | ||
lint: pylint pep8 | ||
|
||
.PHONY: pep8 | ||
pep8: | ||
$(ENV_ACT) pep8 $(PYTEST_TARGET) | ||
|
||
.PHONY: pylint | ||
pylint: | ||
$(ENV_ACT) pylint $(COVERAGE_TARGET) | ||
|
||
.PHONY: pylint-errors | ||
pylint-errors: | ||
$(ENV_ACT) pylint -E $(COVERAGE_TARGET) | ||
|
||
|
||
.PHONY: master | ||
master: | ||
git checkout master | ||
git merge develop | ||
git push origin develop master --tags | ||
git checkout develop | ||
|
||
.PHONY: release | ||
release: | ||
$(ENV_ACT) python setup.py sdist bdist_wheel | ||
$(ENV_ACT) twine upload dist/* | ||
rm -rf dist *.egg* build | ||
|
||
.PHONY: docs | ||
docs: | ||
rm -r docs/_build | ||
$(ENV_ACT) cd docs; make doctest | ||
$(ENV_ACT) cd docs; make html | ||
|
||
.PHONY: serve-docs | ||
serve-docs: | ||
cd docs/_build/html; python2 -m SimpleHTTPServer 8001 | ||
|
||
## | ||
# TravisCI | ||
## | ||
|
||
.PHONY: travisci-install | ||
travisci-install: | ||
pip install -r requirements.txt | ||
|
||
.PHONY: travisci-test | ||
travisci-test: | ||
pep8 $(PYTEST_TARGET) | ||
pylint -E $(COVERAGE_TARGET) | ||
py.test $(PYTEST_ARGS) $(COVERAGE_ARGS) $(COVERAGE_TARGET) $(PYTEST_TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
pep8>=1.5.6 | ||
pylint>=1.2.1 | ||
pytest>=2.5.2 | ||
pytest-cov>=1.6 | ||
python-coveralls>=2.4.2 | ||
requests>=1.1.0 | ||
tox>=1.7.1 | ||
twine>=1.3.1 | ||
wheel>=0.23.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[pytest] | ||
norecursedirs = env | ||
addopts = --doctest-modules -v -s | ||
|
||
# pytest coverage options | ||
[run] | ||
omit = | ||
*/tests/* | ||
*/test_* | ||
*/_compat.py | ||
|
||
[wheel] | ||
universal = 1 | ||
|
||
[pep8] | ||
exclude = .tox,env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,70 @@ | ||
""" | ||
yummly.py | ||
========= | ||
from setuptools import setup | ||
Project: https://github.com/dgilland/yummly.py | ||
with open('VERSION', 'r') as f: | ||
version = f.read() | ||
Documentation: https://github.com/dgilland/yummly.py | ||
""" | ||
|
||
with open('README', 'r') as f: | ||
long_description = f.read() | ||
import os | ||
import sys | ||
from setuptools import setup, find_packages | ||
from setuptools.command.test import test as TestCommand | ||
|
||
|
||
def read(fname): | ||
return open(os.path.join(os.path.dirname(__file__), fname)).read() | ||
|
||
|
||
meta = {} | ||
exec(read('yummly/__meta__.py'), meta) | ||
|
||
|
||
class Tox(TestCommand): | ||
user_options = [ | ||
('tox-args=', 'a', "Arguments to pass to tox") | ||
] | ||
|
||
def initialize_options(self): | ||
TestCommand.initialize_options(self) | ||
self.tox_args = '-c tox.ini' | ||
|
||
def finalize_options(self): | ||
TestCommand.finalize_options(self) | ||
self.test_args = [] | ||
self.test_suite = True | ||
|
||
def run_tests(self): | ||
# Import here because outside the eggs aren't loaded. | ||
import tox | ||
import shlex | ||
|
||
errno = tox.cmdline(args=shlex.split(self.tox_args)) | ||
sys.exit(errno) | ||
|
||
|
||
setup( | ||
setup( | ||
name = 'yummly', | ||
version = version, | ||
description = 'Python package for Yummly API: https://developer.yummly.com', | ||
long_description = long_description, | ||
author = 'Derrick Gilland', | ||
author_email = 'dgilland@gmail.com', | ||
url = 'https://github.com/dgilland/yummly.py', | ||
packages = [ 'yummly' ], | ||
install_requires = ['requests>=1.1.0'], | ||
keywords = 'yummly recipes', | ||
license = 'BSD', | ||
classifiers = [ | ||
name=meta['__title__'], | ||
version=meta['__version__'], | ||
url=meta['__url__'], | ||
license=meta['__license__'], | ||
author=meta['__author__'], | ||
author_email=meta['__email__'], | ||
description=meta['__summary__'], | ||
long_description=read('README.rst'), | ||
packages=find_packages(exclude=['tests']), | ||
install_requires=meta['__install_requires__'], | ||
tests_require=['tox'], | ||
cmdclass={'test': Tox}, | ||
test_suite='tests', | ||
classifiers=[ | ||
'Environment :: Web Environment', | ||
'Intended Audience :: Developers', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'License :: OSI Approved :: BSD License' | ||
'License :: OSI Approved :: MIT License' | ||
] | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Tox (http://tox.testrun.org/) is a tool for running tests | ||
# in multiple virtualenvs. This configuration file will run the | ||
# test suite on all supported python versions. To use it, "pip install tox" | ||
# and then run "tox" from this directory. | ||
|
||
[tox] | ||
envlist = py27, pep8 | ||
|
||
[testenv] | ||
commands = py.test yummly tests [] | ||
deps = | ||
pytest | ||
pytest-cov | ||
|
||
[testenv:pep8] | ||
deps = pep8 | ||
commands = pep8 yummly tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Project metadata. | ||
""" | ||
|
||
__title__ = 'yummly' | ||
__summary__ = 'Python library for Yummly API: https://developer.yummly.com' | ||
__url__ = 'https://github.com/dgilland/yummly.py' | ||
|
||
__version__ = '0.4.1' | ||
__install_requires__ = ['requests>=1.1.0'] | ||
|
||
__author__ = 'Derrick Gilland' | ||
__email__ = 'dgilland@gmail.com' | ||
|
||
__license__ = 'MIT License' |