xref: /petsc/src/binding/petsc4py/makefile (revision 34c645fd3b0199e05bec2fcc32d3597bfeb7f4f2)
1-include ../../../petscdir.mk
2.PHONY: default
3default: build
4default: opt=--inplace
5
6package = petsc4py
7MODULE  = PETSc
8
9PYTHON  = python$(py)
10MPIEXEC = mpiexec
11
12# ----
13
14.PHONY: config build test
15config:
16	${PYTHON} setup.py config ${opt}
17build:
18	${PYTHON} setup.py build ${opt}
19test:
20	${VALGRIND} ${PYTHON} ${PWD}/test/runtests.py ${opt}
21test-%:
22	${MPIEXEC} -n $* ${VALGRIND} ${PYTHON} ${PWD}/test/runtests.py ${opt}
23
24.PHONY: srcbuild srcclean
25srcbuild:
26	${PYTHON} setup.py build_src ${opt}
27srcclean:
28	-${RM} src/${package}/${MODULE}.c
29	-${RM} src/${package}/${MODULE}.h
30	-${RM} src/${package}/${MODULE}_api.h
31
32.PHONY: clean distclean fullclean
33clean: srcclean
34	${PYTHON} setup.py clean --all
35distclean: clean
36	-${RM} -r build  _configtest.* *.py[co]
37	-${RM} -r MANIFEST dist ${package}.egg-info
38	-${RM} -r `find . -name '__pycache__'`
39	-${RM} `find . -name '*.py[co]'`
40fullclean: distclean srcclean docsclean
41	-find . -name '*~' -exec rm -f {} ';'
42
43# ----
44
45.PHONY: install uninstall
46install: build
47	${PYTHON} setup.py install --prefix='' --user ${opt}
48uninstall:
49	-${RM} -r $(shell ${PYTHON} -m site --user-site)/${package}
50	-${RM} -r $(shell ${PYTHON} -m site --user-site)/${package}-*-py*.egg-info
51
52# ----
53
54.PHONY: lint ruff-lint cython-lint
55CYTHONLINT_SRC = src demo
56CYTHONLINT_OPTS =
57RUFF_SRC = .
58RUFF_OPTS = check
59
60cython-lint:
61	conf/cythonize.sh -Wextra -Werror
62	cython-lint ${CYTHONLINT_OPTS} ${CYTHONLINT_SRC}
63
64
65ruff-lint:
66	ruff ${RUFF_OPTS} ${RUFF_SRC}
67
68lint:
69	${RM} -r petsc4py-lint-env
70	${PYTHON} -m venv petsc4py-lint-env
71	. petsc4py-lint-env/bin/activate && python -m pip install -r conf/requirements-lint.txt
72	. petsc4py-lint-env/bin/activate && ${MAKE} cython-lint
73	. petsc4py-lint-env/bin/activate && ${MAKE} ruff-lint
74
75# ----
76
77.PHONY: docs docs-html docs-pdf docs-misc
78docs: docs-html docs-pdf docs-misc
79docs-html: rst2html sphinx-html
80docs-pdf:  sphinx-pdf
81docs-misc: sphinx-man sphinx-info
82
83RST2HTML = $(shell command -v rst2html || command -v rst2html.py || false)
84RST2HTMLOPTS  = --input-encoding=utf-8
85RST2HTMLOPTS += --no-compact-lists
86RST2HTMLOPTS += --cloak-email-addresses
87.PHONY: rst2html
88rst2html: checkdocutils
89	${RST2HTML} ${RST2HTMLOPTS} ./LICENSE.rst  > docs/LICENSE.html
90	${RST2HTML} ${RST2HTMLOPTS} ./CHANGES.rst  > docs/CHANGES.html
91	${RST2HTML} ${RST2HTMLOPTS} docs/index.rst > docs/index.html
92
93SPHINXBUILD = sphinx-build
94SPHINXOPTS  =
95.PHONY: sphinx sphinx-html sphinx-pdf sphinx-man sphinx-info
96sphinx: sphinx-html sphinx-pdf sphinx-man sphinx-info
97sphinx-html:
98	mkdir -p build/doctrees docs/html
99	${SPHINXBUILD} -a -b html -d build/doctrees ${SPHINXOPTS} \
100	docs/source docs/html
101	${RM} docs/html/.buildinfo
102sphinx-pdf:
103	mkdir -p build/doctrees build/latex
104	${SPHINXBUILD} -b latex -d build/doctrees ${SPHINXOPTS} \
105	docs/source build/latex
106	${MAKE} -C build/latex all-pdf > /dev/null
107	mv build/latex/*.pdf docs/
108sphinx-man:
109	mkdir -p build/doctrees build/man
110	${SPHINXBUILD} -b man -d build/doctrees ${SPHINXOPTS} \
111	docs/source build/man
112	mv build/man/*.[137] docs/
113sphinx-info:
114	mkdir -p build/doctrees build/texinfo
115	${SPHINXBUILD} -b texinfo -d build/doctrees ${SPHINXOPTS} \
116	docs/source build/texinfo
117	${MAKE} -C build/texinfo info > /dev/null
118	mv build/texinfo/*.info docs/
119
120.PHONY: docsclean
121docsclean:
122	-${RM} docs/*.html docs/*.pdf
123	-${RM} docs/*.info docs/*.[137]
124	-${RM} -r docs/html
125	-${RM} -r docs/source/demo
126	-${RM} -r docs/source/reference
127	-${RM} docs/source/*.inv
128
129website:
130	env CFLAGS=-O0 python -m pip install .
131	${MAKE} sphinx-html SPHINXOPTS=-Wj2
132	mkdir -p ${LOC}/petsc4py
133	mv docs/html/* ${LOC}/petsc4py
134
135# ----
136
137.PHONY: sdist
138sdist:
139	${PYTHON} setup.py sdist ${opt}
140
141# ----
142