Merge pull request #141 from ets-labs/140_makefile

Add makefile
This commit is contained in:
Roman 2016-10-31 00:12:22 +02:00 committed by GitHub
commit c428c23c42
7 changed files with 43 additions and 47 deletions

View File

@ -1,3 +1,6 @@
[run]
include = dependency_injector/*
omit = tests/*
[html]
directory=reports/unittests/

5
.gitignore vendored
View File

@ -33,7 +33,7 @@ pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
reports/
.tox/
.coverage
.cache
@ -62,8 +62,5 @@ venv/
# SQLite
*.db
# JointJS Experiments
jointjs/
# Vim Rope
.ropeproject/

35
Makefile Normal file
View File

@ -0,0 +1,35 @@
VERSION:=$(shell python setup.py --version)
clean:
# Clean sources
find dependency_injector -name '*.py[co]' -delete
find dependency_injector -name '__pycache__' -delete
find dependency_injector -name '*.c' -delete
find dependency_injector -name '*.so' -delete
# Clean tests
find tests -name '*.py[co]' -delete
find tests -name '__pycache__' -delete
# Clean examples
find examples -name '*.py[co]' -delete
find examples -name '__pycache__' -delete
tests: clean
# Unit tests with coverage report
coverage erase
coverage run --rcfile=./.coveragerc -m unittest2 discover tests
coverage report --rcfile=./.coveragerc
coverage html --rcfile=./.coveragerc
coverage erase
# Static analysis
flake8 --max-complexity=10 dependency_injector/
flake8 --max-complexity=10 examples/
# Code style analysis
pydocstyle dependency_injector/
pydocstyle examples/
publish: clean
# Create and upload build
python setup.py sdist upload
# Create and upload tag
git tag -a $(VERSION) -m 'version $(VERSION)'
git push --tags

View File

@ -10,6 +10,7 @@ follows `Semantic versioning`_
Development version
-------------------
- Remove ``@inject`` decorator.
- Add makefile (``clean``, ``tests`` & ``publish`` commands).
.. - No features.

View File

@ -4,3 +4,6 @@ sphinx
sphinx_rtd_theme
sphinx_autobuild
autodoc
coverage
flake8
pydocstyle

View File

@ -1,10 +1,8 @@
"""`Dependency injector` setup script."""
import os
import re
from setuptools import setup
from setuptools import Command
# Getting description:
@ -20,26 +18,6 @@ with open('dependency_injector/__init__.py') as init_file:
version = re.search('VERSION = \'(.*?)\'', init_file.read()).group(1)
class PublishCommand(Command):
"""Setuptools `publish` command."""
description = "Publish current distribution to PyPi and create tag"
user_options = []
def initialize_options(self):
"""Init options."""
def finalize_options(self):
"""Finalize options."""
def run(self):
"""Command execution."""
self.run_command('sdist')
self.run_command('upload')
os.system('git tag -a {0} -m \'version {0}\''.format(version))
os.system('git push --tags')
setup(name='dependency-injector',
version=version,
description='Dependency injection microframework for Python',
@ -58,9 +36,6 @@ setup(name='dependency-injector',
platforms=['any'],
zip_safe=True,
install_requires=requirements,
cmdclass={
'publish': PublishCommand,
},
keywords=[
'DI',
'Dependency injection',

18
tox.ini
View File

@ -8,24 +8,6 @@ deps=
commands=
unit2 discover tests []
[testenv:dev]
basepython=python2.7
deps=
{[testenv]deps}
coverage
flake8
pydocstyle
commands=
coverage erase
coverage run --rcfile=./.coveragerc -m unittest2 discover tests []
coverage html --rcfile=./.coveragerc
flake8 --max-complexity=10 dependency_injector/
flake8 --max-complexity=10 examples/
pydocstyle dependency_injector/
pydocstyle examples/
[testenv:coveralls]
basepython=python2.7
passenv=TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH