-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
58 lines (44 loc) · 1.77 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import nox
import shutil
from tempfile import TemporaryDirectory
from pathlib import Path
nox.options.default_venv_backend = "uv"
@nox.session
def tests(session):
session.install(".[test]")
session.run("uv", "pip", "list")
session.run("pytest")
@nox.session
def test_py_typed(session):
"""Verify py.typed is properly installed with the package."""
session.install(".")
result = session.run(
"python",
"-c",
"import bfabric, pathlib; p=pathlib.Path(bfabric.__file__).parent/'py.typed'; print(p.exists())",
silent=True,
stderr=None,
)
if not result or result.strip() != "True":
session.error("py.typed not found in installed package")
@nox.session(default=False)
def docs(session):
"""Builds documentation for bfabricPy and app-runner and writes to site directory."""
with TemporaryDirectory() as tmpdir:
session.install(".[doc]")
session.run("mkdocs", "build", "-d", Path(tmpdir) / "build_bfabricpy")
session.install("./app_runner[doc]")
session.run("sphinx-build", "-M", "html", "app_runner/docs", Path(tmpdir) / "build_app_runner")
target_dir = Path("site")
if target_dir.exists():
shutil.rmtree(target_dir)
shutil.copytree(Path(tmpdir) / "build_bfabricpy", target_dir)
shutil.copytree(Path(tmpdir) / "build_app_runner" / "html", target_dir / "app_runner")
@nox.session(default=False)
def publish_docs(session):
"""Publish documentation to GitHub Pages by updating gh-pages branch."""
site_dir = Path("site")
if not site_dir.exists():
session.error("Site directory does not exist. Run 'nox -s docs' first.")
session.install("ghp-import")
session.run("ghp-import", "--force", "--no-jekyll", "--push", "site")