From 3bd19a168a3e22c6522dc51fa7dc012b16325cdc Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Wed, 2 Nov 2016 17:21:40 +0200 Subject: [PATCH] Tune building in debug mode --- .travis.yml | 4 ++-- Makefile | 5 ++--- setup.py | 9 +++++++++ tox.ini | 8 ++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09f22344..e259d161 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,13 @@ language: python install: - pip install tox - pip install cython - - make build + - make cythonize script: - tox python: - 3.5 env: - - TOXENV=coveralls DEBUG=1 + - TOXENV=coveralls DEPENDENCY_INJECTOR_DEBUG_MODE=1 - TOXENV=pylint - TOXENV=flake8 - TOXENV=pydocstyle diff --git a/Makefile b/Makefile index b317bef8..8a7930e3 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,8 @@ CYTHON_SRC := $(shell find dependency_injector -name '*.pyx') CYTHON_DIRECTIVES = C_MACROS = -ifdef DEBUG +ifdef DEPENDENCY_INJECTOR_DEBUG_MODE CYTHON_DIRECTIVES += -Xprofile=True -Xlinetrace=True - C_MACROS += -DCYTHON_TRACE endif @@ -34,7 +33,7 @@ cythonize: build: clean cythonize # Compile C extensions - python setup.py build_ext --inplace $(C_MACROS) + python setup.py build_ext --inplace test: # Unit tests with coverage report diff --git a/setup.py b/setup.py index c91064a2..9fb9ff4b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ """`Dependency injector` setup script.""" +import os import re from setuptools import setup, Extension @@ -17,6 +18,13 @@ with open('requirements.txt') as version: with open('dependency_injector/__init__.py') as init_file: version = re.search('VERSION = \'(.*?)\'', init_file.read()).group(1) +# Defining macros: +defined_macros = list() +if os.environ.get('DEPENDENCY_INJECTOR_DEBUG_MODE') == '1': + defined_macros.append(('CYTHON_TRACE', 1)) + defined_macros.append(('CYTHON_TRACE_NOGIL', 1)) +print(defined_macros) + setup(name='dependency-injector', version=version, @@ -36,6 +44,7 @@ setup(name='dependency-injector', ext_modules=[ Extension('dependency_injector.injections', ['dependency_injector/injections.c'], + define_macros=defined_macros, extra_compile_args=['-O2']), ], package_data={ diff --git a/tox.ini b/tox.ini index c4435e78..27e0c6c7 100644 --- a/tox.ini +++ b/tox.ini @@ -18,18 +18,18 @@ deps= coveralls commands= coverage erase - coverage run --rcfile=./.coveragerc -m unittest2 discover tests [] + coverage run --rcfile=./.coveragerc -m unittest2 discover tests coveralls [testenv:pylint] -basepython=python2.7 +basepython=python3.5 deps= pylint commands= - pylint -f colorized --rcfile=./.pylintrc dependency_injector [testenv:flake8] -basepython=python2.7 +basepython=python3.5 deps= flake8 commands= @@ -37,7 +37,7 @@ commands= flake8 --max-complexity=10 examples/ [testenv:pydocstyle] -basepython=python2.7 +basepython=python3.5 deps= pydocstyle commands=