xref: /petsc/src/binding/petsc4py/makefile (revision 126519442fb4dd57a5f782a20905ab3872bce6dc)
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 check-docs
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
64ruff-lint:
65	ruff ${RUFF_OPTS} ${RUFF_SRC}
66
67lint:
68	${RM} -r petsc4py-lint-env
69	${PYTHON} -m venv petsc4py-lint-env
70	. petsc4py-lint-env/bin/activate && python -m pip install -r conf/requirements-lint.txt
71	. petsc4py-lint-env/bin/activate && ${MAKE} cython-lint
72	. petsc4py-lint-env/bin/activate && ${MAKE} ruff-lint
73
74check-docs:
75	${RM} -r petsc4py-docs-env
76	${PYTHON} -m venv petsc4py-docs-env
77	. petsc4py-docs-env/bin/activate && python -m pip install -r conf/requirements-docs.txt
78	. petsc4py-docs-env/bin/activate && CFLAGS=-O0 python -m pip install .
79	. petsc4py-docs-env/bin/activate && ${MAKE} sphinx-html SPHINXOPTS=-Wj1
80
81# ----
82
83.PHONY: docs docs-html docs-pdf docs-misc
84docs: docs-html docs-pdf docs-misc
85docs-html: rst2html sphinx-html
86docs-pdf:  sphinx-pdf
87docs-misc: sphinx-man sphinx-info
88
89RST2HTML = $(shell command -v rst2html || command -v rst2html.py || false)
90RST2HTMLOPTS  = --input-encoding=utf-8
91RST2HTMLOPTS += --no-compact-lists
92RST2HTMLOPTS += --cloak-email-addresses
93.PHONY: rst2html
94rst2html: checkdocutils
95	${RST2HTML} ${RST2HTMLOPTS} ./LICENSE.rst  > docs/LICENSE.html
96	${RST2HTML} ${RST2HTMLOPTS} ./CHANGES.rst  > docs/CHANGES.html
97	${RST2HTML} ${RST2HTMLOPTS} docs/index.rst > docs/index.html
98
99SPHINXBUILD = sphinx-build
100SPHINXOPTS  =
101.PHONY: sphinx sphinx-html sphinx-pdf sphinx-man sphinx-info
102sphinx: sphinx-html sphinx-pdf sphinx-man sphinx-info
103sphinx-html:
104	mkdir -p build/doctrees docs/html
105	${SPHINXBUILD} -a -b html -d build/doctrees ${SPHINXOPTS} \
106	docs/source docs/html
107	${RM} docs/html/.buildinfo
108sphinx-pdf:
109	mkdir -p build/doctrees build/latex
110	${SPHINXBUILD} -b latex -d build/doctrees ${SPHINXOPTS} \
111	docs/source build/latex
112	${MAKE} -C build/latex all-pdf > /dev/null
113	mv build/latex/*.pdf docs/
114sphinx-man:
115	mkdir -p build/doctrees build/man
116	${SPHINXBUILD} -b man -d build/doctrees ${SPHINXOPTS} \
117	docs/source build/man
118	mv build/man/*.[137] docs/
119sphinx-info:
120	mkdir -p build/doctrees build/texinfo
121	${SPHINXBUILD} -b texinfo -d build/doctrees ${SPHINXOPTS} \
122	docs/source build/texinfo
123	${MAKE} -C build/texinfo info > /dev/null
124	mv build/texinfo/*.info docs/
125
126.PHONY: docsclean
127docsclean:
128	-${RM} docs/*.html docs/*.pdf
129	-${RM} docs/*.info docs/*.[137]
130	-${RM} -r docs/html
131	-${RM} -r docs/source/_build
132	-${RM} -r docs/source/demo
133	-${RM} -r docs/source/reference
134	-${RM} docs/source/*.inv
135
136website:
137	CFLAGS=-O0 python -m pip install .
138	${MAKE} sphinx-html SPHINXOPTS=-Wj2
139	mkdir -p ${LOC}/petsc4py
140	mv docs/html/* ${LOC}/petsc4py
141
142# ----
143
144.PHONY: sdist
145sdist:
146	${PYTHON} setup.py sdist ${opt}
147
148# ----
149