Eric Bower
·
2026-09-08
1#!/usr/bin/env bash
2set -euo pipefail
3
4if ! command -v python3 >/dev/null 2>&1; then
5 echo "error: python3 not found in PATH" >&2
6 exit 1
7fi
8
9if ! command -v ctags >/dev/null 2>&1; then
10 echo "error: ctags not found in PATH" >&2
11 exit 1
12fi
13
14std_dir="$(python3 -c "import sysconfig; print(sysconfig.get_path('stdlib'))" 2>/dev/null || true)"
15
16if [[ -z "${std_dir}" || ! -d "${std_dir}" ]]; then
17 echo "error: could not locate python std directory" >&2
18 exit 1
19fi
20
21cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/tags"
22target="${cache_dir}/python_std.tags"
23
24mkdir -p "${cache_dir}"
25
26echo "Generating Python standard library tags from ${std_dir}..."
27ctags --exclude="*/site-packages/*" \
28 --exclude="*/test/*" \
29 --exclude="*/tests/*" \
30 --exclude="*/idlelib/*" \
31 -f "${target}" "${std_dir}"
32echo "Saved tags to ${target} ($(du -h "${target}" | cut -f1))"