Skip to content

Commit

Permalink
Port makefile and pyproject.toml from template repo and adjust it for…
Browse files Browse the repository at this point in the history
… our needs
  • Loading branch information
stand-by committed Jul 17, 2024
1 parent 634a6e6 commit 9525462
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
111 changes: 111 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = []

0 comments on commit 9525462

Please sign in to comment.