notebooklm
VerifiedInstall, authenticate, troubleshoot, and operate Gemini Notebook through the notebooklm-py CLI or typed async Python API. Use for notebook and source management, grounded chat and research, and artifact generation or download when the user mentions Gemini Notebook, notebooklm-py, the notebooklm CLI, or its Python API. Do not use for the generic Gemini API or unrelated content creation.
scripts/check_base_wheel.py
View on GitHub#!/usr/bin/env python3
"""Prove a built base wheel works without the optional Playwright dependency."""
from __future__ import annotations
import argparse
import os
import re
import subprocess
import sys
import tempfile
import zipfile
from email.parser import BytesParser
from pathlib import Path
EXPECTED_BROWSER_FILES = {
"__init__.py",
"browser_capture.py",
"browser_launch_errors.py",
"headless_reauth.py",
"navigation_errors.py",
"oauth_token.py",
}
def _run(command: list[str], *, env: dict[str, str] | None = None) -> None:
print("+", " ".join(command), flush=True)
subprocess.run(command, check=True, env=env)
def _venv_python(root: Path) -> Path:
if os.name == "nt":
return root / "Scripts" / "python.exe"
return root / "bin" / "python"
def _venv_console(root: Path) -> Path:
if os.name == "nt":
return root / "Scripts" / "notebooklm.exe"
return root / "bin" / "notebooklm"
def _requirement_name(requirement: str) -> str:
"""Extract and normalize the complete distribution name using only the stdlib."""
match = re.match(r"[A-Za-z0-9][A-Za-z0-9._-]*", requirement.lstrip())
return re.sub(r"[-_.]+", "-", match.group()).lower() if match else ""
def _inspect_wheel(wheel: Path) -> None:
"""Validate browser modules and required dependency declarations in a built wheel."""
with zipfile.ZipFile(wheel) as archive:
names = set(archive.namelist())
browser_files = {
Path(name).name
for name in names
if name.startswith("notebooklm/_browser/") and name.endswith(".py")
}
missing = EXPECTED_BROWSER_FILES - browser_files
if missing:
raise RuntimeError(f"wheel is missing _browser modules: {sorted(missing)}")
metadata_names = [name for name in names if name.endswith(".dist-info/METADATA")]
if len(metadata_names) != 1:
raise RuntimeError(f"expected one wheel METADATA file, found {metadata_names}")
metadata = BytesParser().parsebytes(archive.read(metadata_names[0]))
requirements = metadata.get_all("Requires-Dist", [])
# Older Python versions and optional extras can supply this transitively,
# hiding a missing direct dependency even in a clean-install smoke test.
if not any(
_requirement_name(requirement) == "typing-extensions" and ";" not in requirement
for requirement in requirements
):
raise RuntimeError("wheel metadata has no unconditional typing_extensions requirement")
playwright_requirements = [
requirement
for requirement in requirements
if requirement.split(";", 1)[0].strip().lower().startswith("playwright")
]
if not playwright_requirements:
raise RuntimeError("wheel metadata has no Playwright browser-extra requirement")
markers = [
requirement.partition(";")[2].replace("'", '"').replace(" ", "")
for requirement in playwright_requirements
]
if any("extra==" not in marker for marker in markers):
raise RuntimeError(
f"Playwright has an unconditional requirement: {playwright_requirements}"
)
if not any('extra=="browser"' in marker for marker in markers):
raise RuntimeError("wheel metadata does not expose Playwright through the browser extra")
def _check_base_install(wheel: Path, interpreter: Path) -> None:
with tempfile.TemporaryDirectory(prefix="notebooklm-base-wheel-") as directory:
root = Path(directory) / "venv"
_run([str(interpreter), "-m", "venv", str(root)])
python = _venv_python(root)
env = {**os.environ, "PYTHONNOUSERSITE": "1"}
_run(
[
str(python),
"-m",
"pip",
"install",
"--disable-pip-version-check",
str(wheel),
],
env=env,
)
_run(
[
str(python),
"-c",
(
"import importlib.util, sys; "
"assert importlib.util.find_spec('playwright') is None; "
"import notebooklm, notebooklm.auth, notebooklm.client; "
"assert 'notebooklm._browser' not in sys.modules; "
"assert not any(n == 'playwright' or n.startswith('playwright.') "
"for n in sys.modules)"
),
],
env=env,
)
_run(
[
str(python),
"-c",
(
"import sys, notebooklm.notebooklm_cli; "
"assert not any(n == 'playwright' or n.startswith('playwright.') "
"for n in sys.modules)"
),
],
env=env,
)
_run([str(_venv_console(root)), "--help"], env=env)
_run(
[
str(python),
"-c",
(
"import sys; from notebooklm import auth; "
"assert auth.browser_login_channels(); "
"assert not any(n == 'playwright' or n.startswith('playwright.') "
"for n in sys.modules)"
),
],
env=env,
)
_run(
[
str(python),
"-m",
"pip",
"install",
"--disable-pip-version-check",
f"{wheel}[browser]",
],
env=env,
)
_run([str(python), "-c", "import playwright"], env=env)
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--wheel", type=Path, required=True)
parser.add_argument("--python", type=Path, default=Path(sys.executable))
args = parser.parse_args(argv)
wheel = args.wheel.resolve()
interpreter = args.python.resolve()
if not wheel.is_file() or wheel.suffix != ".whl":
parser.error(f"--wheel must name one built wheel: {wheel}")
if not interpreter.is_file():
parser.error(f"--python does not exist: {interpreter}")
_inspect_wheel(wheel)
_check_base_install(wheel, interpreter)
print("base-wheel/no-extra and browser-extra smoke passed")
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |