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 stubtest 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 81stubgen: 82 python -m pip install . 83 python conf/stubgen.py 84 85stubcheck: 86 python -m mypy.stubtest petsc4py --ignore-missing-stub --allowlist conf/stubtest-allowlist --ignore-disjoint-bases 87 88stubdiff: 89 git diff --quiet -- src/petsc4py/PETSc.pyi 90 91stubtest: 92 ${RM} -r petsc4py-stubtest-env 93 ${PYTHON} -m venv petsc4py-stubtest-env 94 . petsc4py-stubtest-env/bin/activate && python -m pip install -r conf/requirements-stubtest.txt 95 . petsc4py-stubtest-env/bin/activate && ${MAKE} stubgen 96 . petsc4py-stubtest-env/bin/activate && ${MAKE} stubcheck 97 . petsc4py-stubtest-env/bin/activate && ${MAKE} stubdiff 98# ---- 99 100.PHONY: docs docs-html docs-pdf docs-misc 101docs: docs-html docs-pdf docs-misc 102docs-html: rst2html sphinx-html 103docs-pdf: sphinx-pdf 104docs-misc: sphinx-man sphinx-info 105 106RST2HTML = $(shell command -v rst2html || command -v rst2html.py || false) 107RST2HTMLOPTS = --input-encoding=utf-8 108RST2HTMLOPTS += --no-compact-lists 109RST2HTMLOPTS += --cloak-email-addresses 110.PHONY: rst2html 111rst2html: checkdocutils 112 ${RST2HTML} ${RST2HTMLOPTS} ./LICENSE.rst > docs/LICENSE.html 113 ${RST2HTML} ${RST2HTMLOPTS} ./CHANGES.rst > docs/CHANGES.html 114 ${RST2HTML} ${RST2HTMLOPTS} docs/index.rst > docs/index.html 115 116SPHINXBUILD = sphinx-build 117SPHINXOPTS = 118.PHONY: sphinx sphinx-html sphinx-pdf sphinx-man sphinx-info 119sphinx: sphinx-html sphinx-pdf sphinx-man sphinx-info 120sphinx-html: 121 mkdir -p build/doctrees docs/html 122 ${SPHINXBUILD} -a -b html -d build/doctrees ${SPHINXOPTS} \ 123 docs/source docs/html 124 ${RM} docs/html/.buildinfo 125sphinx-pdf: 126 mkdir -p build/doctrees build/latex 127 ${SPHINXBUILD} -b latex -d build/doctrees ${SPHINXOPTS} \ 128 docs/source build/latex 129 ${MAKE} -C build/latex all-pdf > /dev/null 130 mv build/latex/*.pdf docs/ 131sphinx-man: 132 mkdir -p build/doctrees build/man 133 ${SPHINXBUILD} -b man -d build/doctrees ${SPHINXOPTS} \ 134 docs/source build/man 135 mv build/man/*.[137] docs/ 136sphinx-info: 137 mkdir -p build/doctrees build/texinfo 138 ${SPHINXBUILD} -b texinfo -d build/doctrees ${SPHINXOPTS} \ 139 docs/source build/texinfo 140 ${MAKE} -C build/texinfo info > /dev/null 141 mv build/texinfo/*.info docs/ 142 143.PHONY: docsclean 144docsclean: 145 -${RM} docs/*.html docs/*.pdf 146 -${RM} docs/*.info docs/*.[137] 147 -${RM} -r docs/html 148 -${RM} -r docs/source/_build 149 -${RM} -r docs/source/demo 150 -${RM} -r docs/source/reference 151 -${RM} docs/source/*.inv 152 153website: 154 CFLAGS=-O0 python -m pip install . 155 ${MAKE} sphinx-html SPHINXOPTS=-Wj2 156 mkdir -p ${LOC}/petsc4py 157 mv docs/html/* ${LOC}/petsc4py 158 159# ---- 160 161.PHONY: sdist 162sdist: 163 ${PYTHON} setup.py sdist ${opt} 164 165# ---- 166