Skip to content

Commit 55cde47

Browse files
authored
Merge pull request #142 from ets-labs/138_cython_injections
Add injections extension
2 parents d485a45 + 82bd1ae commit 55cde47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+324
-276
lines changed

.coveragerc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[run]
2-
include = dependency_injector/*
3-
omit = tests/*
2+
source = src/dependency_injector
3+
omit = tests/unit
4+
plugins = Cython.Coverage
45

56
[html]
67
directory=reports/unittests/

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ venv/
6363
.ropeproject/
6464

6565
# C extensions
66-
dependency_injector/*.c
67-
dependency_injector/*.so
68-
dependency_injector/providers/*.c
69-
dependency_injector/providers/*.so
66+
src/dependency_injector/*.c
67+
src/dependency_injector/*.so
68+
src/dependency_injector/providers/*.c
69+
src/dependency_injector/providers/*.so

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Add <file or directory> to the black list. It should be a base name, not a
44
# path. You may set this option multiple times.
5-
ignore=utils,test
5+
ignore=utils,tests
66

77
[MESSAGES CONTROL]
88

.travis.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
sudo: false
2+
install:
3+
- pip install tox
4+
- pip install cython
5+
- make cythonize
6+
script:
7+
- tox
28
language: python
3-
install: pip install tox
4-
script: tox
59
python:
6-
- 3.5
10+
- 3.5
711
env:
8-
- TOXENV=coveralls
9-
- TOXENV=pylint
10-
- TOXENV=flake8
11-
- TOXENV=pydocstyle
12-
- TOXENV=py26
13-
- TOXENV=py27
14-
- TOXENV=py33
15-
- TOXENV=py34
16-
- TOXENV=py35
17-
- TOXENV=pypy
18-
- TOXENV=pypy3
12+
- TOXENV=coveralls DEPENDENCY_INJECTOR_DEBUG_MODE=1
13+
- TOXENV=pylint
14+
- TOXENV=flake8
15+
- TOXENV=pydocstyle
16+
- TOXENV=py26
17+
- TOXENV=py27
18+
- TOXENV=py33
19+
- TOXENV=py34
20+
- TOXENV=py35
21+
- TOXENV=pypy
22+
- TOXENV=pypy3

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include dependency_injector/*
1+
recursive-include src/dependency_injector *.py *.pyx *.pxd *.c
22
include README.rst
33
include CONTRIBUTORS.rst
44
include LICENSE.rst

Makefile

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,62 @@
1-
VERSION:=$(shell python setup.py --version)
1+
VERSION := $(shell python setup.py --version)
2+
3+
CYTHON_SRC := $(shell find src/dependency_injector -name '*.pyx')
4+
5+
CYTHON_DIRECTIVES =
6+
7+
ifdef DEPENDENCY_INJECTOR_DEBUG_MODE
8+
CYTHON_DIRECTIVES += -Xprofile=True
9+
CYTHON_DIRECTIVES += -Xlinetrace=True
10+
endif
11+
212

313
clean:
414
# Clean sources
5-
find dependency_injector -name '*.py[co]' -delete
6-
find dependency_injector -name '__pycache__' -delete
7-
find dependency_injector -name '*.c' -delete
8-
find dependency_injector -name '*.so' -delete
15+
find src -name '*.py[cod]' -delete
16+
find src -name '__pycache__' -delete
17+
find src -name '*.c' -delete
18+
find src -name '*.so' -delete
19+
find src -name '*.html' -delete
920
# Clean tests
1021
find tests -name '*.py[co]' -delete
1122
find tests -name '__pycache__' -delete
1223
# Clean examples
1324
find examples -name '*.py[co]' -delete
1425
find examples -name '__pycache__' -delete
1526

16-
tests: clean
27+
cythonize:
28+
# Compile Cython to C
29+
cython -a $(CYTHON_DIRECTIVES) $(CYTHON_SRC)
30+
# Move all Cython html reports
31+
mkdir -p reports/cython/
32+
find src -name '*.html' -exec mv {} reports/cython/ \;
33+
34+
build: clean cythonize
35+
# Compile C extensions
36+
python setup.py build_ext --inplace
37+
38+
install: uninstall clean cythonize
39+
pip install -ve .
40+
41+
uninstall:
42+
- pip uninstall -y -q dependency-injector 2> /dev/null
43+
44+
test: build
1745
# Unit tests with coverage report
1846
coverage erase
19-
coverage run --rcfile=./.coveragerc -m unittest2 discover tests
47+
coverage run --rcfile=./.coveragerc -m unittest2 discover tests/unit
2048
coverage report --rcfile=./.coveragerc
2149
coverage html --rcfile=./.coveragerc
22-
coverage erase
50+
51+
check:
2352
# Static analysis
24-
flake8 --max-complexity=10 dependency_injector/
53+
flake8 --max-complexity=10 src/dependency_injector/
2554
flake8 --max-complexity=10 examples/
2655
# Code style analysis
27-
pydocstyle dependency_injector/
56+
pydocstyle src/dependency_injector/
2857
pydocstyle examples/
2958

30-
publish: clean
59+
publish: cythonize
3160
# Create and upload build
3261
python setup.py sdist upload
3362
# Create and upload tag

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#
5757
# The short X.Y version.
5858
# Getting version:
59-
with open('../dependency_injector/__init__.py') as init_file:
59+
with open('../src/dependency_injector/__init__.py') as init_file:
6060
version = re.search('VERSION = \'(.*?)\'', init_file.read()).group(1)
6161

6262
# The full version, including alpha/beta/rc tags.
@@ -281,7 +281,7 @@
281281
# dir menu entry, description, category)
282282
texinfo_documents = [
283283
(master_doc, 'Dependency Injector', u'Dependency Injector Documentation',
284-
author, 'Dependency Injector', 'Python dependency injection framework',
284+
author, 'Dependency Injector', 'Dependency injection microframework for Python',
285285
'Miscellaneous'),
286286
]
287287

docs/main/changelog.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ follows `Semantic versioning`_
99

1010
Development version
1111
-------------------
12+
- Add ``dependency_injector.injections`` module (C extension).
1213
- Remove ``@inject`` decorator.
13-
- Add makefile (``clean``, ``tests`` & ``publish`` commands).
14+
- Add makefile (``clean``, ``test``, ``build``, ``install``, ``uninstall``
15+
& ``publish`` commands).
16+
- Update repository structure:
17+
18+
- Sources are moved under ``src``.
19+
- Tests are moved under ``tests/unit``.
1420

1521
.. - No features.
1622

examples/advanced_usage/inject_flask.py

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

examples/advanced_usage/inject_flask_class_based.py

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

0 commit comments

Comments
 (0)