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