Newer
Older
from pathlib import Path
import nox
DIR = Path(__file__).parent.resolve()
@nox.session(venv_backend="none")
def pre_commit(session: nox.Session) -> None:
"""
Run pre-commit
"""
if "pre_commit" in sys.argv:
session.run("pre-commit", "run", "--all-files")
@nox.session(venv_backend="none")
def dev(session: nox.Session) -> None:
"""
Prepare a .venv folder.
"""
library_output_dir = DIR / "src" / "myproj" / "simulation" / "_csrc"
print(sys.path)
session.run("which", "pip")
"install",
"--no-build-isolation",
"--check-build-dependencies",
f"-Ccmake.define.Python_ROOT_DIR={sys.exec_prefix}",
"-Ccmake.define.CMAKE_EXPORT_COMPILE_COMMANDS=1",
f"-Ccmake.define.CMAKE_LIBRARY_OUTPUT_DIRECTORY={library_output_dir}",
"-Cbuild-dir=build",
@nox.session(reuse_venv=True)
def cpp_lint_slow(session: nox.Session) -> None:
if "cpp_lint_slow" in sys.argv:
cpp_files = glob.glob("**/*.cc", recursive=True)
session.run("clang-tidy", "-p", "build", *cpp_files)
@nox.session(reuse_venv=True)
def rr_run(session: nox.Session) -> None:
"""
Run sp-repo-review.
"""
session.install("sp-repo-review[cli]")
session.run("repo-review", ".")
@nox.session
def rr_pylint(session: nox.Session) -> None:
"""
Run PyLint.
"""
# This needs to be installed into the package environment, and is slower
# than a pre-commit check
session.install("-e.")
session.install("pylint>=3.2")
session.run("pylint", "myproj.simulation", *session.posargs)