6 LXMLVERSION=$(shell cat version.txt)
8 PARALLEL=$(shell $(PYTHON) -c 'import sys; print("-j7" if sys.version_info >= (3, 5) else "")' )
9 PARALLEL3=$(shell $(PYTHON3) -c 'import sys; print("-j7" if sys.version_info >= (3, 5) else "")' )
10 PYTHON_WITH_CYTHON=$(shell $(PYTHON) -c 'import Cython.Build.Dependencies' >/dev/null 2>/dev/null && echo " --with-cython" || true)
11 PY3_WITH_CYTHON=$(shell $(PYTHON3) -c 'import Cython.Build.Dependencies' >/dev/null 2>/dev/null && echo " --with-cython" || true)
12 CYTHON_WITH_COVERAGE=$(shell $(PYTHON) -c 'import Cython.Coverage; import sys; assert not hasattr(sys, "pypy_version_info")' >/dev/null 2>/dev/null && echo " --coverage" || true)
13 CYTHON3_WITH_COVERAGE=$(shell $(PYTHON3) -c 'import Cython.Coverage; import sys; assert not hasattr(sys, "pypy_version_info")' >/dev/null 2>/dev/null && echo " --coverage" || true)
15 MANYLINUX_LIBXML2_VERSION=2.9.9
16 MANYLINUX_LIBXSLT_VERSION=1.1.33
17 MANYLINUX_IMAGE_X86_64=quay.io/pypa/manylinux1_x86_64
18 MANYLINUX_IMAGE_686=quay.io/pypa/manylinux1_i686
20 .PHONY: all inplace inplace3 rebuild-sdist sdist build require-cython wheel_manylinux wheel
26 $(PYTHON) setup.py $(SETUPFLAGS) build_ext -i $(PYTHON_WITH_CYTHON) --warnings --with-coverage $(PARALLEL)
29 $(PYTHON3) setup.py $(SETUPFLAGS) build_ext -i $(PY3_WITH_CYTHON) --warnings --with-coverage $(PARALLEL3)
31 rebuild-sdist: require-cython
32 rm -f dist/lxml-$(LXMLVERSION).tar.gz
33 find src -name '*.c' -exec rm -f {} \;
34 $(MAKE) dist/lxml-$(LXMLVERSION).tar.gz
36 dist/lxml-$(LXMLVERSION).tar.gz:
37 $(PYTHON) setup.py $(SETUPFLAGS) sdist $(PYTHON_WITH_CYTHON)
39 sdist: dist/lxml-$(LXMLVERSION).tar.gz
42 $(PYTHON) setup.py $(SETUPFLAGS) build $(PYTHON_WITH_CYTHON)
45 @[ -n "$(PYTHON_WITH_CYTHON)" ] || { \
46 echo "NOTE: missing Cython - please use this command to install it: $(PYTHON) -m pip install Cython"; false; }
48 wheel_manylinux: wheel_manylinux64 wheel_manylinux32
50 wheel_manylinux32 wheel_manylinux64: dist/lxml-$(LXMLVERSION).tar.gz
51 time docker run --rm -t \
53 -e CFLAGS="-O3 -g1 -march=core2 -pipe -fPIC -flto" \
54 -e LDFLAGS="$(LDFLAGS) -flto" \
55 -e LIBXML2_VERSION="$(MANYLINUX_LIBXML2_VERSION)" \
56 -e LIBXSLT_VERSION="$(MANYLINUX_LIBXSLT_VERSION)" \
57 -e WHEELHOUSE=wheelhouse_$(subst wheel_,,$@) \
58 $(if $(patsubst %32,,$@),$(MANYLINUX_IMAGE_X86_64),$(MANYLINUX_IMAGE_686)) \
59 bash /io/tools/manylinux/build-wheels.sh /io/$<
62 $(PYTHON) setup.py $(SETUPFLAGS) bdist_wheel $(PYTHON_WITH_CYTHON)
65 $(PYTHON) setup.py $(SETUPFLAGS) bdist_wheel $(PYTHON_WITH_CYTHON) --static-deps
68 $(PYTHON) test.py $(TESTFLAGS) $(TESTOPTS)
71 $(PYTHON) test.py $(TESTFLAGS) $(TESTOPTS) $(CYTHON_WITH_COVERAGE)
73 test_inplace3: inplace3
74 $(PYTHON3) test.py $(TESTFLAGS) $(TESTOPTS) $(CYTHON3_WITH_COVERAGE)
76 valgrind_test_inplace: inplace
77 valgrind --tool=memcheck --leak-check=full --num-callers=30 --suppressions=valgrind-python.supp \
80 gdb_test_inplace: inplace
81 @echo "file $(PYTHON)\nrun test.py" > .gdb.command
82 gdb -x .gdb.command -d src -d src/lxml
84 bench_inplace: inplace
85 $(PYTHON) benchmark/bench_etree.py -i
86 $(PYTHON) benchmark/bench_xpath.py -i
87 $(PYTHON) benchmark/bench_xslt.py -i
88 $(PYTHON) benchmark/bench_objectify.py -i
91 $(PYTHON) test.py -f $(TESTFLAGS) $(TESTOPTS)
93 ftest_inplace: inplace
94 $(PYTHON) test.py -f $(TESTFLAGS) $(TESTOPTS)
98 @[ -x "`which epydoc`" ] \
99 && (cd src && echo "Generating API docs ..." && \
100 PYTHONPATH=. epydoc -v --docformat "restructuredtext en" \
101 -o ../doc/html/api --exclude='[.]html[.]tests|[.]_' \
102 --exclude-introspect='[.]usedoctest' \
103 --name "lxml API" --url / lxml/) \
104 || (echo "not generating epydoc API documentation")
107 PYTHONPATH=src:$(PYTHONPATH) $(PYTHON) doc/mkhtml.py doc/html . ${LXMLVERSION}
109 html: inplace website apihtml s5
112 $(MAKE) -C doc/s5 slides
117 @[ -x "`which epydoc`" ] \
118 && (cd src && echo "Generating API docs ..." && \
119 PYTHONPATH=. epydoc -v --latex --docformat "restructuredtext en" \
120 -o ../doc/pdf --exclude='([.]html)?[.]tests|[.]_' \
121 --exclude-introspect='html[.]clean|[.]usedoctest' \
122 --name "lxml API" --url / lxml/) \
123 || (echo "not generating epydoc API documentation")
126 $(PYTHON) doc/mklatex.py doc/pdf . ${LXMLVERSION}
127 (cd doc/pdf && pdflatex lxmldoc.tex \
128 && pdflatex lxmldoc.tex \
129 && pdflatex lxmldoc.tex)
130 @cp doc/pdf/lxmldoc.pdf doc/pdf/lxmldoc-${LXMLVERSION}.pdf
131 @echo "PDF available as doc/pdf/lxmldoc-${LXMLVERSION}.pdf"
133 # Two pdflatex runs are needed to build the correct Table of contents.
139 valtest: valgrind_test_inplace
141 gdbtest: gdb_test_inplace
148 find . \( -name '*.o' -o -name '*.so' -o -name '*.py[cod]' -o -name '*.dll' \) -exec rm -f {} \;
152 $(MAKE) -C doc/s5 clean
153 rm -f doc/html/*.html
157 realclean: clean docclean
158 find src -name '*.c' -exec rm -f {} \;
160 $(PYTHON) setup.py clean -a --without-cython