diff --git a/.coveragerc b/.coveragerc index 9369b60a..3c6ac723 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [run] +plugins = Cython.Coverage include = dependency_injector/* -omit = tests/* [html] directory=reports/unittests/ diff --git a/.travis.yml b/.travis.yml index 52b4cbb6..5df802f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: python install: - pip install tox - pip install cython - - make compile + - make build DEBUG=1 script: - tox python: diff --git a/Makefile b/Makefile index 9f74a5c1..b317bef8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,15 @@ -VERSION:=$(shell python setup.py --version) +VERSION := $(shell python setup.py --version) + +CYTHON_SRC := $(shell find dependency_injector -name '*.pyx') + +CYTHON_DIRECTIVES = +C_MACROS = + +ifdef DEBUG + CYTHON_DIRECTIVES += -Xprofile=True -Xlinetrace=True + C_MACROS += -DCYTHON_TRACE +endif + clean: # Clean sources @@ -6,6 +17,7 @@ clean: find dependency_injector -name '__pycache__' -delete find dependency_injector -name '*.c' -delete find dependency_injector -name '*.so' -delete + find dependency_injector -name '*.html' -delete # Clean tests find tests -name '*.py[co]' -delete find tests -name '__pycache__' -delete @@ -13,24 +25,25 @@ clean: find examples -name '*.py[co]' -delete find examples -name '__pycache__' -delete -compile: clean +cythonize: # Compile Cython to C - cython -a dependency_injector/injections.pyx + cython -a $(CYTHON_DIRECTIVES) $(CYTHON_SRC) # Move all Cython html reports mkdir -p reports/cython/ find dependency_injector -name '*.html' -exec mv {} reports/cython/ \; -build: compile +build: clean cythonize # Compile C extensions - python setup.py build_ext --inplace + python setup.py build_ext --inplace $(C_MACROS) -tests: build +test: # 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 + +check: # Static analysis flake8 --max-complexity=10 dependency_injector/ flake8 --max-complexity=10 examples/ @@ -38,7 +51,7 @@ tests: build pydocstyle dependency_injector/ pydocstyle examples/ -publish: build tests +publish: cythonize # Create and upload build python setup.py sdist upload # Create and upload tag diff --git a/tox.ini b/tox.ini index df81f63a..575bfdf8 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ basepython=python2.7 passenv=TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH deps= {[testenv]deps} + cython coverage coveralls commands=