Debian Codegraph @

third_party/python/aiohttp/Makefile

raw
1 # Some simple testing tasks (sorry, UNIX only).
2
3 to-hash-one = $(dir $1).hash/$(addsuffix .hash,$(notdir $1))
4 to-hash = $(foreach fname,$1,$(call to-hash-one,$(fname)))
5
6 CYS := $(wildcard aiohttp/*.pyx) $(wildcard aiohttp/*.pyi) $(wildcard aiohttp/*.pxd)
7 PYXS := $(wildcard aiohttp/*.pyx)
8 CS := $(wildcard aiohttp/*.c)
9 PYS := $(wildcard aiohttp/*.py)
10 IN := doc-spelling lint cython dev
11 ALLS := $(sort $(CYS) $(CS) $(PYS) $(REQS))
12
13
14 .PHONY: all
15 all: test
16
17 tst:
18 @echo $(call to-hash,requirements/cython.txt)
19 @echo $(call to-hash,aiohttp/%.pyx)
20
21
22 # Recipe from https://www.cmcrossroads.com/article/rebuilding-when-files-checksum-changes
23 FORCE:
24
25 # check_sum.py works perfectly fine but slow when called for every file from $(ALLS)
26 # (perhaps even several times for each file).
27 # That is why much less readable but faster solution exists
28 ifneq (, $(shell command -v sha256sum))
29 %.hash: FORCE
30 $(eval $@_ABS := $(abspath $@))
31 $(eval $@_NAME := $($@_ABS))
32 $(eval $@_HASHDIR := $(dir $($@_ABS)))
33 $(eval $@_TMP := $($@_HASHDIR)../$(notdir $($@_ABS)))
34 $(eval $@_ORIG := $(subst /.hash/../,/,$(basename $($@_TMP))))
35 @#echo ==== $($@_ABS) $($@_HASHDIR) $($@_NAME) $($@_TMP) $($@_ORIG)
36 @if ! (sha256sum --check $($@_ABS) 1>/dev/null 2>/dev/null); then \
37 mkdir -p $($@_HASHDIR); \
38 echo re-hash $($@_ORIG); \
39 sha256sum $($@_ORIG) > $($@_ABS); \
40 fi
41 else
42 %.hash: FORCE
43 @./tools/check_sum.py $@ # --debug
44 endif
45
46 # Enumerate intermediate files to don't remove them automatically.
47 .SECONDARY: $(call to-hash,$(ALLS))
48
49 .update-pip:
50 @python -m pip install --upgrade pip
51
52 .install-cython: .update-pip $(call to-hash,requirements/cython.txt)
53 @python -m pip install -r requirements/cython.in -c requirements/cython.txt
54 @touch .install-cython
55
56 aiohttp/_find_header.c: $(call to-hash,aiohttp/hdrs.py ./tools/gen.py)
57 ./tools/gen.py
58
59 # _find_headers generator creates _headers.pyi as well
60 aiohttp/%.c: aiohttp/%.pyx $(call to-hash,$(CYS)) aiohttp/_find_header.c
61 cython -3 -o $@ $< -I aiohttp -Werror
62
63 vendor/llhttp/node_modules: vendor/llhttp/package.json
64 cd vendor/llhttp; npm ci
65
66 .llhttp-gen: vendor/llhttp/node_modules
67 $(MAKE) -C vendor/llhttp generate
68 @touch .llhttp-gen
69
70 .PHONY: generate-llhttp
71 generate-llhttp: .llhttp-gen
72
73 .PHONY: cythonize
74 cythonize: .install-cython $(PYXS:.pyx=.c)
75
76 .install-deps: .install-cython $(PYXS:.pyx=.c) $(call to-hash,$(CYS) $(REQS))
77 @python -m pip install -r requirements/dev.in -c requirements/dev.txt
78 @touch .install-deps
79
80 .PHONY: lint
81 lint: fmt mypy
82
83 .PHONY: fmt format
84 fmt format:
85 python -m pre_commit run --all-files --show-diff-on-failure
86
87 .PHONY: mypy
88 mypy:
89 mypy
90
91 .develop: .install-deps generate-llhttp $(call to-hash,$(PYS) $(CYS) $(CS))
92 python -m pip install -e . -c requirements/runtime-deps.txt
93 @touch .develop
94
95 .PHONY: test
96 test: .develop
97 @pytest -q
98
99 .PHONY: vtest
100 vtest: .develop
101 @pytest -s -v
102 @python -X dev -m pytest -s -v -m dev_mode
103
104 .PHONY: vvtest
105 vvtest: .develop
106 @pytest -vv
107 @python -X dev -m pytest -s -v -m dev_mode
108
109
110 define run_tests_in_docker
111 DOCKER_BUILDKIT=1 docker build --build-arg PYTHON_VERSION=$(1) --build-arg AIOHTTP_NO_EXTENSIONS=$(2) -t "aiohttp-test-$(1)-$(2)" -f tools/testing/Dockerfile .
112 docker run --rm -ti -v `pwd`:/src -w /src "aiohttp-test-$(1)-$(2)" $(TEST_SPEC)
113 endef
114
115 .PHONY: test-3.8-no-extensions test-3.8 test-3.9-no-extensions test
116 test-3.8-no-extensions:
117 $(call run_tests_in_docker,3.8,y)
118 test-3.8:
119 $(call run_tests_in_docker,3.8,n)
120 test-3.9-no-extensions:
121 $(call run_tests_in_docker,3.9,y)
122 test-3.9:
123 $(call run_tests_in_docker,3.9,n)
124 test-3.10-no-extensions:
125 $(call run_tests_in_docker,3.10,y)
126 test-3.10:
127 $(call run_tests_in_docker,3.10,n)
128
129 .PHONY: clean
130 clean:
131 @rm -rf `find . -name __pycache__`
132 @rm -rf `find . -name .hash`
133 @rm -rf `find . -name .md5` # old styling
134 @rm -f `find . -type f -name '*.py[co]' `
135 @rm -f `find . -type f -name '*~' `
136 @rm -f `find . -type f -name '.*~' `
137 @rm -f `find . -type f -name '@*' `
138 @rm -f `find . -type f -name '#*#' `
139 @rm -f `find . -type f -name '*.orig' `
140 @rm -f `find . -type f -name '*.rej' `
141 @rm -f `find . -type f -name '*.md5' ` # old styling
142 @rm -f .coverage
143 @rm -rf htmlcov
144 @rm -rf build
145 @rm -rf cover
146 @make -C docs clean
147 @python setup.py clean
148 @rm -f aiohttp/*.so
149 @rm -f aiohttp/*.pyd
150 @rm -f aiohttp/*.html
151 @rm -f aiohttp/_frozenlist.c
152 @rm -f aiohttp/_find_header.c
153 @rm -f aiohttp/_http_parser.c
154 @rm -f aiohttp/_http_writer.c
155 @rm -f aiohttp/_websocket.c
156 @rm -rf .tox
157 @rm -f .develop
158 @rm -f .flake
159 @rm -rf aiohttp.egg-info
160 @rm -f .install-deps
161 @rm -f .install-cython
162 @rm -rf vendor/llhttp/node_modules
163 @rm -f .llhttp-gen
164 @$(MAKE) -C vendor/llhttp clean
165
166 .PHONY: doc
167 doc:
168 @make -C docs html SPHINXOPTS="-W --keep-going -n -E"
169 @echo "open file://`pwd`/docs/_build/html/index.html"
170
171 .PHONY: doc-spelling
172 doc-spelling:
173 @make -C docs spelling SPHINXOPTS="-W --keep-going -n -E"
174
175 .PHONY: install
176 install: .update-pip
177 @python -m pip install -r requirements/dev.in -c requirements/dev.txt
178
179 .PHONY: install-dev
180 install-dev: .develop
181
182 .PHONY: sync-direct-runtime-deps
183 sync-direct-runtime-deps:
184 @echo Updating 'requirements/runtime-deps.in' from 'setup.cfg'... >&2
185 @python requirements/sync-direct-runtime-deps.py