noxfile.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import nox
  2. nox.options.sessions = ["lint", "tests", "tests_packaging"]
  3. @nox.session(reuse_venv=True)
  4. def lint(session: nox.Session) -> None:
  5. """
  6. Lint the codebase (except for clang-format/tidy).
  7. """
  8. session.install("pre-commit")
  9. session.run("pre-commit", "run", "-a")
  10. @nox.session
  11. def tests(session: nox.Session) -> None:
  12. """
  13. Run the tests (requires a compiler).
  14. """
  15. tmpdir = session.create_tmp()
  16. session.install("pytest", "cmake")
  17. session.run(
  18. "cmake",
  19. "-S",
  20. ".",
  21. "-B",
  22. tmpdir,
  23. "-DPYBIND11_WERROR=ON",
  24. "-DDOWNLOAD_CATCH=ON",
  25. "-DDOWNLOAD_EIGEN=ON",
  26. *session.posargs
  27. )
  28. session.run("cmake", "--build", tmpdir)
  29. session.run("cmake", "--build", tmpdir, "--config=Release", "--target", "check")
  30. @nox.session
  31. def tests_packaging(session: nox.Session) -> None:
  32. """
  33. Run the packaging tests.
  34. """
  35. session.install("-r", "tests/requirements.txt", "--prefer-binary")
  36. session.run("pytest", "tests/extra_python_package")
  37. @nox.session(reuse_venv=True)
  38. def docs(session: nox.Session) -> None:
  39. """
  40. Build the docs. Pass "serve" to serve.
  41. """
  42. session.install("-r", "docs/requirements.txt")
  43. session.chdir("docs")
  44. if "pdf" in session.posargs:
  45. session.run("sphinx-build", "-M", "latexpdf", ".", "_build")
  46. return
  47. session.run("sphinx-build", "-M", "html", ".", "_build")
  48. if "serve" in session.posargs:
  49. session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
  50. session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
  51. elif session.posargs:
  52. session.error("Unsupported argument to docs")
  53. @nox.session(reuse_venv=True)
  54. def make_changelog(session: nox.Session) -> None:
  55. """
  56. Inspect the closed issues and make entries for a changelog.
  57. """
  58. session.install("ghapi", "rich")
  59. session.run("python", "tools/make_changelog.py")
  60. @nox.session(reuse_venv=True)
  61. def build(session: nox.Session) -> None:
  62. """
  63. Build SDists and wheels.
  64. """
  65. session.install("build")
  66. session.run("python", "-m", "build")
  67. session.run("python", "-m", "build", env={"PYBIND11_GLOBAL_SDIST": "1"})