@@ -36,6 +36,30 @@ way to get all of that is the container.
3636 sandbox with a host clone of the repo bind-mounted in and ` pip install -e `
3737 pointed at it, so edits on the host are live inside the container.
3838
39+ ** Shadow a library build with ` PYTHONPATH ` (no image rebuild).** When you need
40+ the container to run a * different* build of a pure-Python library than the one
41+ baked into its venv — a feature worktree, an unreleased branch, this repo's own
42+ ` src/ ` against a stale image — prepend the host checkout to ` PYTHONPATH ` . Python
43+ resolves the prepended path first, so the on-disk version shadows
44+ ` /app/.venv/... ` without touching the image. This is the local-testing
45+ counterpart of a git-ref dependency (e.g. ` cs_util @ develop ` in
46+ ` pyproject.toml ` ): the dep change makes CI build the right version; the shadow
47+ lets you test that version * now* , before any rebuild. The recipe:
48+
49+ ``` bash
50+ apptainer exec --bind /n17data,/automnt < image.sif> bash -c \
51+ " cd <repo-worktree> && \
52+ PYTHONPATH=/path/to/libfoo-checkout:<repo-worktree>/src \
53+ python -m pytest <targets> -o addopts='' -q"
54+ ```
55+
56+ Notes: the checkout path is the ** parent** of the importable package dir (the
57+ dir containing ` foo/ ` , not ` foo/ ` itself); list several ` : ` -separated to stack
58+ shadows; ` -o addopts='' ` clears ` pyproject.toml ` 's pytest defaults when a plugin
59+ they reference (e.g. ` pytest-cov ` ) isn't in the image. Use this for a quick
60+ verify; land the real fix as the ` pyproject.toml ` / ` uv.lock ` dep change so CI
61+ and the next image agree.
62+
3963** Testing container changes: build remotely, pull locally.** Don't
4064` apptainer build ` images on a cluster — quotas are tight and the build is slow.
4165The loop for any change to ` Dockerfile ` / ` pyproject.toml ` / ` uv.lock ` is: edit
0 commit comments