Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Query Google NotebookLM notebooks from Claude Code for source-grounded, citation-backed answers from Gemini.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/__init__.py
1#!/usr/bin/env python32"""3NotebookLM Skill Scripts Package4Provides automatic environment management for all scripts5"""67import os8import sys9import subprocess10from pathlib import Path111213def ensure_venv_and_run():14"""15Ensure virtual environment exists and run the requested script.16This is called when any script is imported or run directly.17"""18# Only do this if we're not already in the skill's venv19skill_dir = Path(__file__).parent.parent20venv_dir = skill_dir / ".venv"2122# Check if we're in a venv23in_venv = hasattr(sys, 'real_prefix') or (24hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix25)2627# Check if it's OUR venv28if in_venv:29venv_path = Path(sys.prefix)30if venv_path == venv_dir:31# We're already in the correct venv32return3334# We need to set up or switch to our venv35if not venv_dir.exists():36print("🔧 First-time setup detected...")37print(" Creating isolated environment for NotebookLM skill...")38print(" This ensures clean dependency management...")3940# Create venv41import venv42venv.create(venv_dir, with_pip=True)4344# Install requirements45requirements_file = skill_dir / "requirements.txt"46if requirements_file.exists():47if os.name == 'nt': # Windows48pip_exe = venv_dir / "Scripts" / "pip.exe"49else:50pip_exe = venv_dir / "bin" / "pip"5152print(" Installing dependencies in isolated environment...")53subprocess.run(54[str(pip_exe), "install", "-q", "-r", str(requirements_file)],55check=True56)5758# Also install patchright's chromium59print(" Setting up browser automation...")60if os.name == 'nt':61python_exe = venv_dir / "Scripts" / "python.exe"62else:63python_exe = venv_dir / "bin" / "python"6465subprocess.run(66[str(python_exe), "-m", "patchright", "install", "chromium"],67check=True,68capture_output=True69)7071print("✅ Environment ready! All dependencies isolated in .venv/")7273# If we're here and not in the venv, we should recommend using the venv74if not in_venv:75print("\n⚠️ Running outside virtual environment")76print(" Recommended: Use scripts/run.py to ensure clean execution")77print(" Or activate: source .venv/bin/activate")787980# Check environment when module is imported81ensure_venv_and_run()