Skip to content

refactor(ns): convert campus to a PEP 420 namespace portion - #986

Merged
nycomp merged 2 commits into
weeklyfrom
refactor/campus-namespace-portion
Oct 28, 2026
Merged

nycomp merged 2 commits into
weeklyfrom
refactor/campus-namespace-portion

Conversation

@nycomp

@nycomp nycomp commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Convert campus from a pkgutil-style namespace package into a native PEP 420 namespace portion: delete campus/__init__.py, which contained only the pkgutil.extend_path shim and a docstring (no code, no __version__, no attribute consumers — verified by repo-wide grep). Every distribution that contributes subpackages under campus/ now ships an init-less portion, and Python merges them across sys.path.

This is the namespace groundwork for the #970 phase-3 carve (campus-common and friends as separate distributions): consumer import syntax (from campus.model import ..., import campus.common, from campus import flask_campus) is unchanged — those are submodule imports, which resolve identically under PEP 420.

Changes

  • Delete campus/__init__.py — the only pkgutil reference in the codebase; its stated purpose ("extend with campus-python") is stale since the SDK installs a separate top-level campus_python namespace.
  • Add scripts/audit_wheel_namespace.py — post-poetry build audit that fails the build if any wheel ships campus/__init__.py, ships .py files in a subpackage dir without __init__.py, or ships nothing under campus/. The failure mode this guards against (one stale regular package silently shadowing all other dists' portions) is otherwise invisible until runtime.
  • Fix pre-existing gap caught by the audit on its first run: campus/yapper/backends/ shipped .py files with no __init__.py (accidental nested namespace portion; imported only via relative imports inside yapper). Now a regular package.
  • docs/PACKAGING.md — new "Namespace Package Rules (PEP 420)" section: the init-less rule, the audit command, and the stale-venv hazard (rebuild, don't layer installs).

Testing

  • 872 unit tests pass in the worktree venv
  • Full contract suite passes in the worktree venv
  • poetry build + python scripts/audit_wheel_namespace.py → wheel ships an init-less campus/ portion with all subpackages intact
  • ruff check green on all changed/new files

Refs #970 (phase-3 groundwork; non-closing).

Delete campus/__init__.py (pkgutil extend_path shim, zero code, zero
attribute consumers) so `campus` is a native namespace package: every
distribution contributing subpackages under campus/ ships an init-less
portion and Python merges them across sys.path. Groundwork for the
campus-common carve (#970 phase 3).

- scripts/audit_wheel_namespace.py: post-build wheel audit that fails on
  any campus/__init__.py, missing subpackage inits, or empty portions
- docs/PACKAGING.md: document the namespace rules and the audit command

Verified: 872 unit + full contract suite green in a worktree venv;
poetry build wheel passes the namespace audit. Refs #970.
backends/ shipped .py files with no __init__.py - an accidental nested
namespace portion that only imported via PEP 420 fallback. Caught by the
new scripts/audit_wheel_namespace.py on its first run; docstring-only
init, no behavior change. Refs #970.
@nycomp
nycomp merged commit accb47b into weekly Oct 28, 2026
22 checks passed
@nycomp
nycomp deleted the refactor/campus-namespace-portion branch October 28, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants