1+ #!/usr/bin/env -S uv run -q
2+
3+ # /// script
4+ # dependencies = ["nox>=2025.2.9"]
5+ # ///
6+
17from __future__ import annotations
28
39import argparse
4- import shutil
510from pathlib import Path
611
712import nox
813
9- DIR = Path (__file__ ).parent .resolve ()
14+ nox .needs_version = ">=2025.2.9"
15+ nox .options .default_venv_backend = "uv|virtualenv"
1016
11- nox .options .sessions = ["lint" , "pylint" , "tests" ]
17+ DIR = Path (__file__ ).parent .resolve ()
18+ PYPROJECT = nox .project .load_toml ("pyproject.toml" )
19+ TEST_DEPS = nox .project .dependency_groups (PYPROJECT , "test" )
20+ DOCS_DEPS = nox .project .dependency_groups (PYPROJECT , "docs" )
1221
1322
1423@nox .session
@@ -36,11 +45,11 @@ def tests(session: nox.Session) -> None:
3645 """
3746 Run the unit and regular tests. Use --cov to activate coverage.
3847 """
39- session .install (".[test]" )
48+ session .install ("-e." , * TEST_DEPS )
4049 session .run ("pytest" , * session .posargs )
4150
4251
43- @nox .session
52+ @nox .session ( default = False )
4453def docs (session : nox .Session ) -> None :
4554 """
4655 Build the docs. Pass "--serve" to serve.
@@ -56,7 +65,7 @@ def docs(session: nox.Session) -> None:
5665 if args .builder != "html" and args .serve :
5766 session .error ("Must not specify non-HTML builder with --serve" )
5867
59- session .install (".[docs]" )
68+ session .install ("-e." , * DOCS_DEPS )
6069 session .chdir ("docs" )
6170
6271 if args .builder == "linkcheck" :
@@ -83,7 +92,7 @@ def docs(session: nox.Session) -> None:
8392 session .run ("python" , "-m" , "http.server" , "8000" , "-d" , "_build/html" )
8493
8594
86- @nox .session
95+ @nox .session ( default = False )
8796def build_api_docs (session : nox .Session ) -> None :
8897 """
8998 Build (regenerate) API docs.
@@ -102,15 +111,15 @@ def build_api_docs(session: nox.Session) -> None:
102111 )
103112
104113
105- @nox .session
114+ @nox .session ( default = False )
106115def build (session : nox .Session ) -> None :
107116 """
108117 Build an SDist and wheel.
109118 """
110119
111- build_p = DIR .joinpath ("build" )
112- if build_p .exists ():
113- shutil .rmtree (build_p )
114-
115120 session .install ("build" )
116121 session .run ("python" , "-m" , "build" )
122+
123+
124+ if __name__ == "__main__" :
125+ nox .main ()
0 commit comments