From 95254626954bdabda8aef12189de98db5e433013 Mon Sep 17 00:00:00 2001 From: Eugene Rublenko <16805621+stand-by@users.noreply.github.com> Date: Tue, 16 Jul 2024 21:11:59 -0400 Subject: [PATCH] Port makefile and pyproject.toml from template repo and adjust it for our needs --- Makefile | 41 ++++++++++++++++++ pyproject.toml | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 Makefile create mode 100644 pyproject.toml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9c355c6 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +.PHONY: build +build: + cmake -B build + cmake --build build --parallel + # TODO in general python build should internally trigger cmake, but for now + # let's keep cmake lines here as we don't have any python build process yet + python -m pip cache purge + python -m pip install --upgrade pip + python -m pip install ".[dev]" + python -m build . + +.PHONY: tests +tests: + ctest --test-dir build + python -m pytest fast_pauli/py/tests + python -m pytest tests + +.PHONY: clean +clean: + rm -rf build dist + +docs-build: + cd docs && \ + python -m sphinx -T -W --keep-going -b html -d _build/doctrees -D language=en . ./html + +livehtml: + sphinx-autobuild docs docs/_build/html + +.PHONY: clean-docs +clean-docs: + rm -rf docs/html docs/_build + +lint-check: + ruff check ./fast_pauli/py ./tests && \ + mypy ./fast_pauli/py ./tests + +lint-fix: + ruff check --fix ./fast_pauli/py ./tests + +lint-write: + ruff format ./fast_pauli/py ./tests \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a35c523 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,111 @@ +[build-system] +requires = [ + "setuptools>=64", + "build", + "setuptools_scm[toml]>=8", +] +build-backend = "setuptools.build_meta" + +[project] +name = "fast_pauli" +readme = "README.md" +description = "fast pauli" +dependencies = [ + "numpy", + "scipy", +] +dynamic = ["version"] + +[project.optional-dependencies] +dev = [ + "clang-format", + "cmake-format", + "pre-commit", + "build", + "mypy", + "ruff", + "pytest", + "setuptools_scm[toml]>=8", + "sphinx", + "sphinx_rtd_theme", + "sphinx-autobuild", +] +examples = [ +] + +[tool.setuptools] +py-modules = ["fast_pauli"] + +[tool.setuptools_scm] +version_file = "fast_pauli/__version__.py" + +[tool.mypy] +warn_redundant_casts = true +warn_unused_ignores = true + +# Needed because of bug in MyPy +disallow_subclassing_any = false + +mypy_path = "stubs" + +disallow_untyped_calls = true +disallow_untyped_defs = true +check_untyped_defs = true +warn_return_any = true +no_implicit_optional = true +strict_optional = true +ignore_missing_imports = true + +exclude = [] + +[tool.ruff] +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", + ".venv", + "fast_pauli/__version__.py", +] + +line-length = 88 +indent-width = 4 + +target-version="py38" + +[tool.ruff.lint] + +# Ruff Rules https://docs.astral.sh/ruff/rules/ +# F - PyFlakes (https://docs.astral.sh/ruff/rules/#pyflakes-f) +# E, W - pycodestyle (https://docs.astral.sh/ruff/rules/#pycodestyle-e-w) +# I - Isort (https://docs.astral.sh/ruff/rules/#isort-i) +# N - PEP-8 Naming (https://docs.astral.sh/ruff/rules/#pep8-naming-n) +# D - pydocstyle (https://docs.astral.sh/ruff/rules/#pydocstyle-d) +# YTT - flake8-2020 (https://docs.astral.sh/ruff/rules/#flake8-2020-ytt) +# ASYNC flake8-async (https://docs.astral.sh/ruff/rules/#flake8-async-async) + +select = ["F", "E", "W", "I", "N", "D", "YTT", "ASYNC"] + +ignore = []