github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/pybind11/noxfile.py (about) 1 import os 2 3 import nox 4 5 nox.needs_version = ">=2022.1.7" 6 nox.options.sessions = ["lint", "tests", "tests_packaging"] 7 8 PYTHON_VERSIONS = [ 9 "3.6", 10 "3.7", 11 "3.8", 12 "3.9", 13 "3.10", 14 "3.11", 15 "pypy3.7", 16 "pypy3.8", 17 "pypy3.9", 18 ] 19 20 if os.environ.get("CI", None): 21 nox.options.error_on_missing_interpreters = True 22 23 24 @nox.session(reuse_venv=True) 25 def lint(session: nox.Session) -> None: 26 """ 27 Lint the codebase (except for clang-format/tidy). 28 """ 29 session.install("pre-commit") 30 session.run("pre-commit", "run", "-a", *session.posargs) 31 32 33 @nox.session(python=PYTHON_VERSIONS) 34 def tests(session: nox.Session) -> None: 35 """ 36 Run the tests (requires a compiler). 37 """ 38 tmpdir = session.create_tmp() 39 session.install("cmake") 40 session.install("-r", "tests/requirements.txt") 41 session.run( 42 "cmake", 43 "-S.", 44 f"-B{tmpdir}", 45 "-DPYBIND11_WERROR=ON", 46 "-DDOWNLOAD_CATCH=ON", 47 "-DDOWNLOAD_EIGEN=ON", 48 *session.posargs, 49 ) 50 session.run("cmake", "--build", tmpdir) 51 session.run("cmake", "--build", tmpdir, "--config=Release", "--target", "check") 52 53 54 @nox.session 55 def tests_packaging(session: nox.Session) -> None: 56 """ 57 Run the packaging tests. 58 """ 59 60 session.install("-r", "tests/requirements.txt", "--prefer-binary") 61 session.run("pytest", "tests/extra_python_package", *session.posargs) 62 63 64 @nox.session(reuse_venv=True) 65 def docs(session: nox.Session) -> None: 66 """ 67 Build the docs. Pass "serve" to serve. 68 """ 69 70 session.install("-r", "docs/requirements.txt") 71 session.chdir("docs") 72 73 if "pdf" in session.posargs: 74 session.run("sphinx-build", "-M", "latexpdf", ".", "_build") 75 return 76 77 session.run("sphinx-build", "-M", "html", ".", "_build") 78 79 if "serve" in session.posargs: 80 session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit") 81 session.run("python", "-m", "http.server", "8000", "-d", "_build/html") 82 elif session.posargs: 83 session.error("Unsupported argument to docs") 84 85 86 @nox.session(reuse_venv=True) 87 def make_changelog(session: nox.Session) -> None: 88 """ 89 Inspect the closed issues and make entries for a changelog. 90 """ 91 session.install("ghapi", "rich") 92 session.run("python", "tools/make_changelog.py") 93 94 95 @nox.session(reuse_venv=True) 96 def build(session: nox.Session) -> None: 97 """ 98 Build SDists and wheels. 99 """ 100 101 session.install("build") 102 session.log("Building normal files") 103 session.run("python", "-m", "build", *session.posargs) 104 session.log("Building pybind11-global files (PYBIND11_GLOBAL_SDIST=1)") 105 session.run( 106 "python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"} 107 )