summaryrefslogtreecommitdiff
path: root/Makefile
blob: 283194c61bd9a866b5a335d42ac0643098a5f76a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
PACKAGENAME=Cython
PYTHON?=python
TESTOPTS?=
REPO = git://github.com/cython/cython.git
VERSION?=$(shell sed -ne 's|^__version__\s*=\s*"\([^"]*\)".*|\1|p' Cython/Shadow.py)
PARALLEL?=$(shell ${PYTHON} -c 'import sys; print("-j5" if sys.version_info >= (3,5) else "")' || true)

MANYLINUX1_IMAGE_X86_64=quay.io/pypa/manylinux1_x86_64
MANYLINUX1_IMAGE_686=quay.io/pypa/manylinux1_i686
MANYLINUX_IMAGE_X86_64=quay.io/pypa/manylinux_2_24_x86_64
MANYLINUX_IMAGE_686=quay.io/pypa/manylinux_2_24_i686

all:    local

local:
	${PYTHON} setup.py build_ext --inplace $(PARALLEL)

plocal:
	${PYTHON} setup.py build_ext --inplace --cython-profile $(PARALLEL)

sdist: dist/$(PACKAGENAME)-$(VERSION).tar.gz

dist/$(PACKAGENAME)-$(VERSION).tar.gz:
	$(PYTHON) setup.py sdist

pywheel: dist/$(PACKAGENAME)-$(VERSION)-py2.py3-none-any.whl

dist/$(PACKAGENAME)-$(VERSION)-py2.py3-none-any.whl:
	${PYTHON} setup.py bdist_wheel --no-cython-compile --universal
	[ -f "$@" ]  # check that we generated the expected universal wheel

TMPDIR = .repo_tmp
.git: .gitrev
	rm -rf $(TMPDIR)
	git clone -n $(REPO) $(TMPDIR)
	cd $(TMPDIR) && git reset -q "$(shell cat .gitrev)"
	mv $(TMPDIR)/.git .
	rm -rf $(TMPDIR)
	git ls-files -d | xargs git checkout --

# Create a git repo from an unpacked source directory.
repo: .git


clean:
	@echo Cleaning Source
	@rm -fr build
	@rm -f *.py[co] */*.py[co] */*/*.py[co] */*/*/*.py[co]
	@rm -f *.so */*.so */*/*.so
	@rm -f *.pyd */*.pyd */*/*.pyd
	@rm -f *~ */*~ */*/*~
	@rm -f core */core
	@rm -f Cython/*.c
	@rm -f Cython/Compiler/*.c
	@rm -f Cython/Plex/*.c
	@rm -f Cython/Tempita/*.c
	@rm -f Cython/Runtime/refnanny.c
	@(cd Demos; $(MAKE) clean)

testclean:
	rm -fr BUILD TEST_TMP

test:	testclean
	${PYTHON} runtests.py -vv ${TESTOPTS}

checks:
	${PYTHON} runtests.py -vv --no-unit --no-doctest --no-file --no-pyregr --no-examples

s5:
	$(MAKE) -C Doc/s5 slides

wheel_manylinux: wheel_manylinux64 wheel_manylinux32

wheel_manylinux32 wheel_manylinux64: dist/$(PACKAGENAME)-$(VERSION).tar.gz
	echo "Building wheels for $(PACKAGENAME) $(VERSION)"
	mkdir -p wheelhouse_$(subst wheel_,,$@)
	for dockerimage in $(if $(patsubst %32,,$@),$(MANYLINUX1_IMAGE_X86_64) $(MANYLINUX_IMAGE_X86_64),$(MANYLINUX1_IMAGE_686) $(MANYLINUX_IMAGE_686)); do \
		time docker run --rm -t \
			-v $(shell pwd):/io \
			-e CFLAGS="-O3 -g0 -mtune=generic -pipe -fPIC" \
			-e LDFLAGS="$(LDFLAGS) -fPIC" \
			-e WHEELHOUSE=wheelhouse_$(subst wheel_,,$@) \
			"$$dockerimage" \
			bash -c '\
				rm -fr /opt/python/*pypy* ; \
				for cpdir in /opt/python/*27* ; do \
				 	if [ -d "$$cpdir" ]; \
				 	then rm -fr /opt/python/*3[78912]; \
 					else rm -fr /opt/python/*{27*,3[456]*}; \
 					fi; break; \
				done ; \
				ls /opt/python/ ; \
				for PYBIN in /opt/python/*/bin; do \
				$$PYBIN/python -V; \
				{ $$PYBIN/pip wheel -w /io/$$WHEELHOUSE /io/$< & } ; \
				done; wait; \
				for whl in /io/$$WHEELHOUSE/$(PACKAGENAME)-$(VERSION)-*-linux_*.whl; do auditwheel repair $$whl -w /io/$$WHEELHOUSE; done' ; \
	done