Debian Codegraph @

Makefile

raw
1 PYTHON2?=python
2 PYTHON?=python3
3 SETUPFLAGS=
4 PACKAGENAME=fastrlock
5 VERSION=$(shell python -c 'import re; f=open("fastrlock/__init__.py"); print(re.search("__version__\s*=\s*[\x27\x22](.+)[\x27\x22]", f.read()).group(1)); f.close()')
6
7 PYTHON_WITH_CYTHON=$(shell $(PYTHON) -c 'import Cython.Compiler' >/dev/null 2>/dev/null && echo " --with-cython" || true)
8 PY2_WITH_CYTHON=$(shell $(PYTHON2) -c 'import Cython.Compiler' >/dev/null 2>/dev/null && echo " --with-cython" || true)
9
10 # manylinux1 images still include Python 2.7
11 MANYLINUX_PYTHON?=cp*
12 MANYLINUX_IMAGES= \
13 manylinux1_x86_64 \
14 manylinux1_i686 \
15 manylinux_2_24_x86_64 \
16 manylinux_2_24_i686 \
17 manylinux_2_24_aarch64 \
18 manylinux_2_28_x86_64 \
19 manylinux_2_28_aarch64 \
20 musllinux_1_1_x86_64 \
21 musllinux_1_1_aarch64
22
23 .PHONY: all version inplace sdist build clean wheel_manylinux wheel
24
25 all: inplace
26
27
28 version:
29 @echo $(VERSION)
30
31 inplace:
32 $(PYTHON) setup.py $(SETUPFLAGS) build_ext -i $(PYTHON_WITH_CYTHON)
33
34 sdist dist/$(PACKAGENAME)-$(VERSION).tar.gz:
35 $(PYTHON) setup.py $(SETUPFLAGS) sdist $(PYTHON_WITH_CYTHON)
36
37 build:
38 $(PYTHON) setup.py $(SETUPFLAGS) build $(PYTHON_WITH_CYTHON)
39
40 wheel:
41 $(PYTHON) setup.py $(SETUPFLAGS) bdist_wheel $(PYTHON_WITH_CYTHON)
42
43 qemu-user-static:
44 docker run --rm --privileged hypriot/qemu-register
45
46 wheel_manylinux: sdist $(addprefix wheel_,$(MANYLINUX_IMAGES))
47 $(addprefix wheel_,$(filter-out %_x86_64, $(filter-out %_i686, $(MANYLINUX_IMAGES)))): qemu-user-static
48
49 wheel_%: dist/$(PACKAGENAME)-$(VERSION).tar.gz
50 echo "Building wheels for $(PACKAGENAME) $(VERSION)"
51 mkdir -p wheelhouse_$(subst wheel_,,$@)
52 time docker run --rm -t \
53 -v $(shell pwd):/io \
54 -e CFLAGS="-O3 -g1 -mtune=generic -pipe -fPIC" \
55 -e LDFLAGS="$(LDFLAGS) -fPIC" \
56 -e WHEELHOUSE=wheelhouse_$(subst wheel_,,$@) \
57 quay.io/pypa/$(subst wheel_,,$@) \
58 bash -c '\
59 rm -fr $(PACKAGENAME)-$(VERSION)/; \
60 tar zxf /io/$< && cd $(PACKAGENAME)-$(VERSION)/ || exit 1; \
61 for PYBIN in /opt/python/$(MANYLINUX_PYTHON)/bin; do \
62 PYVER="$$($$PYBIN/python -V)"; \
63 PROFDIR="prof-$${PYVER// /_}"; \
64 echo $$PYVER; \
65 $$PYBIN/pip install -U pip setuptools; \
66 make clean; rm -fr $$PROFDIR; \
67 CFLAGS="$$CFLAGS -fprofile-generate -fprofile-dir=$$PROFDIR" $$PYBIN/python setup.py build_ext -i; \
68 $$PYBIN/python lockbench.py flock quick; \
69 CFLAGS="$$CFLAGS -fprofile-use -fprofile-correction -fprofile-dir=$$PROFDIR" $$PYBIN/python setup.py build_ext -i -f; \
70 $$PYBIN/python lockbench.py rlock flock quick; \
71 CFLAGS="$$CFLAGS -fprofile-use -fprofile-correction -fprofile-dir=$$PROFDIR" $$PYBIN/python setup.py bdist_wheel; \
72 done; \
73 for whl in dist/$(PACKAGENAME)-$(VERSION)-*-linux_*.whl; do auditwheel repair $$whl -w /io/$$WHEELHOUSE; done; \
74 '
75
76 clean:
77 find . \( -name '*.o' -o -name '*.so' -o -name '*.py[cod]' -o -name '*.dll' \) -exec rm -f {} \;
78 rm -rf build